##### Coverage Report - com.ctrip.framework.apollo.biz.service.NamespaceLockService

Classes in this File | Line Coverage | Branch Coverage | Complexity
NamespaceLockService |
20% | 1/5
N/A | N/A
| 1.0;1

1 |  |
     package com.ctrip.framework.apollo.biz.service;
2 |  |
3 |  |
     import com.ctrip.framework.apollo.biz.entity.NamespaceLock;
4 |  |
     import com.ctrip.framework.apollo.biz.repository.NamespaceLockRepository;
5 |  |
6 |  |
     import org.springframework.beans.factory.annotation.Autowired;
7 |  |
     import org.springframework.stereotype.Service;
8 |  |
     import org.springframework.transaction.annotation.Transactional;
9 |  |
10 |  |
     @Service
11 | 1 |
     public class NamespaceLockService {
12 |  |
13 |  |
       @Autowired
14 |  |
       private NamespaceLockRepository namespaceLockRepository;
15 |  |
16 |  |
17 |  |
       public NamespaceLock findLock(Long namespaceId){
18 | 0 |
         return namespaceLockRepository.findByNamespaceId(namespaceId);
19 |  |
       }
20 |  |
21 |  |
       @Transactional
22 |  |
       public NamespaceLock tryLock(NamespaceLock lock){
23 | 0 |
         return namespaceLockRepository.save(lock);
24 |  |
       }
25 |  |
26 |  |
       @Transactional
27 |  |
       public void unlock(Long namespaceId){
28 | 0 |
         namespaceLockRepository.deleteByNamespaceId(namespaceId);
29 | 0 |
       }
30 |  |
     }