Search in sources :

Example 1 with InstallationCommand

use of io.gravitee.cockpit.api.command.installation.InstallationCommand in project gravitee-management-rest-api by gravitee-io.

the class InstallationCommandHandlerTest method handle.

@Test
public void handle() {
    final InstallationEntity installation = new InstallationEntity();
    installation.setId(INSTALLATION_ID);
    installation.getAdditionalInformation().put(CUSTOM_KEY, CUSTOM_VALUE);
    InstallationPayload installationPayload = new InstallationPayload();
    InstallationCommand command = new InstallationCommand(installationPayload);
    installationPayload.setId(INSTALLATION_ID);
    installationPayload.setStatus("ACCEPTED");
    when(installationService.getOrInitialize()).thenReturn(installation);
    TestObserver<InstallationReply> obs = cut.handle(command).test();
    obs.awaitTerminalEvent();
    obs.assertValue(reply -> reply.getCommandId().equals(command.getId()) && reply.getCommandStatus().equals(CommandStatus.SUCCEEDED));
    final HashMap<String, String> expectedAdditionalInfos = new HashMap<>();
    expectedAdditionalInfos.put(CUSTOM_KEY, CUSTOM_VALUE);
    expectedAdditionalInfos.put(InstallationService.COCKPIT_INSTALLATION_STATUS, "ACCEPTED");
    verify(installationService, times(1)).setAdditionalInformation(expectedAdditionalInfos);
}
Also used : InstallationCommand(io.gravitee.cockpit.api.command.installation.InstallationCommand) InstallationEntity(io.gravitee.rest.api.model.InstallationEntity) HashMap(java.util.HashMap) InstallationPayload(io.gravitee.cockpit.api.command.installation.InstallationPayload) InstallationReply(io.gravitee.cockpit.api.command.installation.InstallationReply) Test(org.junit.Test)

Example 2 with InstallationCommand

use of io.gravitee.cockpit.api.command.installation.InstallationCommand in project gravitee-management-rest-api by gravitee-io.

the class InstallationCommandHandlerTest method handleWithException.

@Test
public void handleWithException() {
    final InstallationEntity installation = new InstallationEntity();
    installation.setId(INSTALLATION_ID);
    installation.getAdditionalInformation().put(CUSTOM_KEY, CUSTOM_VALUE);
    InstallationPayload installationPayload = new InstallationPayload();
    InstallationCommand command = new InstallationCommand(installationPayload);
    installationPayload.setId(INSTALLATION_ID);
    installationPayload.setStatus("ACCEPTED");
    when(installationService.getOrInitialize()).thenReturn(installation);
    when(installationService.setAdditionalInformation(anyMap())).thenThrow(new TechnicalManagementException());
    TestObserver<InstallationReply> obs = cut.handle(command).test();
    obs.awaitTerminalEvent();
    obs.assertValue(reply -> reply.getCommandId().equals(command.getId()) && reply.getCommandStatus().equals(CommandStatus.ERROR));
}
Also used : InstallationCommand(io.gravitee.cockpit.api.command.installation.InstallationCommand) InstallationEntity(io.gravitee.rest.api.model.InstallationEntity) InstallationPayload(io.gravitee.cockpit.api.command.installation.InstallationPayload) InstallationReply(io.gravitee.cockpit.api.command.installation.InstallationReply) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException) Test(org.junit.Test)

Aggregations

InstallationCommand (io.gravitee.cockpit.api.command.installation.InstallationCommand)2 InstallationPayload (io.gravitee.cockpit.api.command.installation.InstallationPayload)2 InstallationReply (io.gravitee.cockpit.api.command.installation.InstallationReply)2 InstallationEntity (io.gravitee.rest.api.model.InstallationEntity)2 Test (org.junit.Test)2 TechnicalManagementException (io.gravitee.rest.api.service.exceptions.TechnicalManagementException)1 HashMap (java.util.HashMap)1