use of io.gravitee.repository.management.model.Installation in project gravitee-management-rest-api by gravitee-io.
the class InstallationServiceImpl method setAdditionalInformation.
@Override
public InstallationEntity setAdditionalInformation(Map<String, String> additionalInformation) {
try {
final Optional<Installation> optInstallation = this.installationRepository.find();
if (optInstallation.isPresent()) {
Installation installation = optInstallation.get();
installation.setAdditionalInformation(additionalInformation);
installation.setUpdatedAt(new Date());
return convert(this.installationRepository.update(installation));
}
} catch (final Exception ex) {
LOGGER.error("Error while updating installation : {}", ex.getMessage());
throw new TechnicalManagementException("Error while updating installation", ex);
}
throw new InstallationNotFoundException("");
}
use of io.gravitee.repository.management.model.Installation in project gravitee-management-rest-api by gravitee-io.
the class InstallationServiceImpl method createInstallation.
private InstallationEntity createInstallation() {
final Date now = Date.from(Instant.now());
final Installation installation = new Installation();
installation.setId(UuidString.generateRandom());
installation.setCreatedAt(now);
installation.setUpdatedAt(now);
installation.setAdditionalInformation(new HashMap<>());
try {
return convert(this.installationRepository.create(installation));
} catch (final Exception ex) {
LOGGER.error("Error while creating installation : {}", ex.getMessage());
throw new TechnicalManagementException("Error while creating installation", ex);
}
}
use of io.gravitee.repository.management.model.Installation in project gravitee-management-rest-api by gravitee-io.
the class InstallationServiceTest method init.
@Before
public void init() throws TechnicalException {
reset(installationRepository);
installation = new Installation();
installation.setId(INSTALLATION_ID);
installation.setCreatedAt(NOW);
installation.setUpdatedAt(NOW);
installation.setAdditionalInformation(ADDITIONAL_INFORMATION);
when(installationRepository.find()).thenReturn(Optional.of(installation));
}
use of io.gravitee.repository.management.model.Installation 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"));
}
Aggregations