SpaceConfigCleanUp { @PostConstruct public void postConstruct() { executeCleanUp(); } SpaceConfigCleanUp(); @Inject  SpaceConfigCleanUp(final OrganizationalUnitService orgUnitService,
                              final SpaceConfigStorageRegistry spaceConfigStorageRegistry); @PostConstruct void postConstruct();  }
@Test public void cleanUpSpaceConfigStorageWhenAlreadyDoneTest() throws IOException { final SpaceConfigStorageImpl spaceConfigStorage = setupConfigStorage(); setupMarker(true); spaceConfigCleanUp.postConstruct(); verify(spaceConfigStorage, never()).loadSpaceInfo(); verify(spaceConfigStorage, never()).saveSpaceInfo(any()); verify(git, never()).resetWithSquash(anyString()); }
@Test public void cleanUpSpaceConfigStorageWhenUpdateNotNeededTest() throws IOException { final SpaceConfigStorageImpl spaceConfigStorage = setupConfigStorage(); setupMarker(false); final SpaceInfo spaceInfo = mock(SpaceInfo.class); doReturn(spaceInfo).when(spaceConfigStorage).loadSpaceInfo(); final RepositoryInfo repositoryInfo = setupRepositoryInfo(createEnvMap(false)); doReturn(Collections.nCopies(5, repositoryInfo)).when(spaceInfo).getRepositories(); spaceConfigCleanUp.postConstruct(); verify(spaceConfigStorage, never()).saveSpaceInfo(any()); verify(git, never()).resetWithSquash(anyString()); }
@Test public void cleanUpSpaceConfigStorageWhenUpdateNeededTest() throws IOException { final SpaceConfigStorageImpl spaceConfigStorage = setupConfigStorage(); setupMarker(false); final SpaceInfo spaceInfo = mock(SpaceInfo.class); doReturn(spaceInfo).when(spaceConfigStorage).loadSpaceInfo(); final RepositoryInfo repositoryInfo = setupRepositoryInfo(createEnvMap(true)); doReturn(Collections.nCopies(5, repositoryInfo)).when(spaceInfo).getRepositories(); spaceConfigCleanUp.postConstruct(); verify(spaceConfigStorage).saveSpaceInfo(any()); verify(git).resetWithSquash(anyString()); }
@Test public void cleanUpSpaceConfigStorageWhenUpdatePartiallyNeededTest() throws IOException { final SpaceConfigStorageImpl spaceConfigStorage = setupConfigStorage(); setupMarker(false); final SpaceInfo spaceInfo = mock(SpaceInfo.class); doReturn(spaceInfo).when(spaceConfigStorage).loadSpaceInfo(); final List<RepositoryInfo> repositoryInfos = new ArrayList<>(); repositoryInfos.addAll(Collections.nCopies(3, setupRepositoryInfo(createEnvMap(true)))); repositoryInfos.addAll(Collections.nCopies(3, setupRepositoryInfo(createEnvMap(false)))); doReturn(repositoryInfos).when(spaceInfo).getRepositories(); spaceConfigCleanUp.postConstruct(); verify(spaceConfigStorage).saveSpaceInfo(any()); verify(git).resetWithSquash(anyString()); }