GovernanceRepositoryFacade implements AutoCloseable { @Override public void close() { registryRepository.close(); if (registryRepository != configurationRepository) { configurationRepository.close(); } } GovernanceRepositoryFacade(final GovernanceConfiguration config); @Override void close();  }
@Test public void assertCloseWithoutAdditionalConfigurationRepository() { GovernanceRepositoryFacade actual = new GovernanceRepositoryFacade( new GovernanceConfiguration("test", new GovernanceCenterConfiguration("ALL", "127.0.0.1:8888", new Properties()), true)); TestAllRepository repository = mock(TestAllRepository.class); FieldUtil.setField(actual, "registryRepository", repository); FieldUtil.setField(actual, "configurationRepository", repository); actual.close(); verify(repository).close(); }
@Test public void assertCloseWithAdditionalConfigurationRepository() { GovernanceRepositoryFacade actual = new GovernanceRepositoryFacade(new GovernanceConfiguration("test", new GovernanceCenterConfiguration("ALL", "127.0.0.1:8888", new Properties()), new GovernanceCenterConfiguration("CONFIG", "127.0.0.1:9999", new Properties()), true)); RegistryRepository registryRepository = mock(RegistryRepository.class); ConfigurationRepository configurationRepository = mock(ConfigurationRepository.class); FieldUtil.setField(actual, "registryRepository", registryRepository); FieldUtil.setField(actual, "configurationRepository", configurationRepository); actual.close(); verify(registryRepository).close(); verify(configurationRepository).close(); }