### Question:
ContentManipulationLockService { public boolean createLock(String providerName) { synchronized (CFGFILE_NAME) { List<String> locks = getCurrentLocks(); if (locks != null) { if (locks.contains(API_ID_ALL) || locks.contains(providerName)) return false; } else { locks = new ArrayList<>(); } locks.add(providerName); storeCurrentLocks(locks); return true; } }  boolean isLockedForProvider(String providerName); List<String> getLockInfo(); boolean createLock(String providerName); void createLockAll(); boolean removeLock(String providerName); void removeLockAll(); static final String API_ID_ALL; }### Answer:
@SuppressWarnings("unchecked") @Test public void createLock() { ContentManipulationLockService tested = getTested(); Mockito.when(tested.configService.get(ContentManipulationLockService.CFGFILE_NAME)).thenReturn(null); Mockito.doAnswer(new StoreValidationgAnswer(PROVIDER_1)).when(tested.configService) .create(Mockito.eq(ContentManipulationLockService.CFGFILE_NAME), Mockito.anyMap()); Assert.assertTrue(tested.createLock(PROVIDER_1)); Mockito.verify(tested.configService).get(ContentManipulationLockService.CFGFILE_NAME); Mockito.verify(tested.configService).create(Mockito.eq(ContentManipulationLockService.CFGFILE_NAME), Mockito.anyMap()); Mockito.verifyNoMoreInteractions(tested.configService); Mockito.reset(tested.configService); Mockito.when(tested.configService.get(ContentManipulationLockService.CFGFILE_NAME)).thenReturn(createCfgFileP1P2()); Mockito.doAnswer(new StoreValidationgAnswer(PROVIDER_1, PROVIDER_2, PROVIDER_3)).when(tested.configService) .create(Mockito.eq(ContentManipulationLockService.CFGFILE_NAME), Mockito.anyMap()); Assert.assertTrue(tested.createLock(PROVIDER_3)); Mockito.verify(tested.configService).get(ContentManipulationLockService.CFGFILE_NAME); Mockito.verify(tested.configService).create(Mockito.eq(ContentManipulationLockService.CFGFILE_NAME), Mockito.anyMap()); Mockito.verifyNoMoreInteractions(tested.configService); Mockito.reset(tested.configService); Mockito.when(tested.configService.get(ContentManipulationLockService.CFGFILE_NAME)).thenReturn(createCfgFileP1P2()); Assert.assertFalse(tested.createLock(PROVIDER_2)); Mockito.verify(tested.configService).get(ContentManipulationLockService.CFGFILE_NAME); Mockito.verifyNoMoreInteractions(tested.configService); Mockito.reset(tested.configService); Mockito.when(tested.configService.get(ContentManipulationLockService.CFGFILE_NAME)).thenReturn(createCfgFileAll()); Assert.assertFalse(tested.createLock(PROVIDER_2)); Mockito.verify(tested.configService).get(ContentManipulationLockService.CFGFILE_NAME); Mockito.verifyNoMoreInteractions(tested.configService); }