use of io.gravitee.rest.api.model.InstallationEntity in project gravitee-management-rest-api by gravitee-io.
the class DefaultInstallationUpgrader method upgrade.
@Override
public boolean upgrade() {
final InstallationEntity installation = installationService.getOrInitialize();
logger.info("Current installation id is [{}]", installation.getId());
return true;
}
use of io.gravitee.rest.api.model.InstallationEntity in project gravitee-management-rest-api by gravitee-io.
the class InstallationServiceTest method shouldUpdateAdditionalInformation.
@Test
public void shouldUpdateAdditionalInformation() throws TechnicalException {
Map<String, String> newAdditionalInformation = new HashMap<>();
newAdditionalInformation.put("key1", "value1");
Installation updatedInstallation = new Installation(installation);
updatedInstallation.setAdditionalInformation(newAdditionalInformation);
updatedInstallation.setUpdatedAt(new Date());
when(installationRepository.update(any(Installation.class))).thenReturn(updatedInstallation);
final InstallationEntity updatedInstallationEntity = installationService.setAdditionalInformation(newAdditionalInformation);
verify(installationRepository).find();
verify(installationRepository).update(ArgumentMatchers.argThat(argument -> argument != null && INSTALLATION_ID.equals(argument.getId()) && NOW.equals(argument.getCreatedAt()) && NOW.before(argument.getUpdatedAt()) && newAdditionalInformation.equals(argument.getAdditionalInformation())));
assertNotNull(updatedInstallationEntity);
assertEquals(INSTALLATION_ID, updatedInstallationEntity.getId());
assertEquals(NOW, updatedInstallationEntity.getCreatedAt());
assertEquals(1, updatedInstallationEntity.getAdditionalInformation().size());
assertEquals("value1", updatedInstallationEntity.getAdditionalInformation().get("key1"));
}
use of io.gravitee.rest.api.model.InstallationEntity in project gravitee-management-rest-api by gravitee-io.
the class InstallationServiceTest method shouldGetInstallationIfExists.
@Test
public void shouldGetInstallationIfExists() throws TechnicalException {
final InstallationEntity installationEntity = installationService.getOrInitialize();
verify(installationRepository).find();
verify(installationRepository, times(0)).create(any());
assertNotNull(installationEntity);
assertEquals(INSTALLATION_ID, installationEntity.getId());
assertEquals(NOW, installationEntity.getCreatedAt());
assertEquals(NOW, installationEntity.getUpdatedAt());
assertEquals(2, installationEntity.getAdditionalInformation().size());
assertEquals(COCKPIT_INSTALLATION_ID, installationEntity.getAdditionalInformation().get(InstallationService.COCKPIT_INSTALLATION_ID));
assertEquals(COCKPIT_INSTALLATION_STATUS, installationEntity.getAdditionalInformation().get(InstallationService.COCKPIT_INSTALLATION_STATUS));
}
use of io.gravitee.rest.api.model.InstallationEntity in project gravitee-management-rest-api by gravitee-io.
the class InstallationServiceTest method shouldCreateInstallationIfNotFound.
@Test
public void shouldCreateInstallationIfNotFound() throws TechnicalException {
when(installationRepository.find()).thenReturn(Optional.empty());
when(installationRepository.create(any())).thenReturn(installation);
final InstallationEntity installationEntity = installationService.getOrInitialize();
verify(installationRepository).find();
verify(installationRepository).create(any());
assertNotNull(installationEntity);
assertEquals(INSTALLATION_ID, installationEntity.getId());
assertEquals(NOW, installationEntity.getCreatedAt());
assertEquals(NOW, installationEntity.getUpdatedAt());
assertEquals(2, installationEntity.getAdditionalInformation().size());
assertEquals(COCKPIT_INSTALLATION_ID, installationEntity.getAdditionalInformation().get(InstallationService.COCKPIT_INSTALLATION_ID));
assertEquals(COCKPIT_INSTALLATION_STATUS, installationEntity.getAdditionalInformation().get(InstallationService.COCKPIT_INSTALLATION_STATUS));
}
Aggregations