Search in sources :

Example 1 with HelloPayload

use of io.gravitee.cockpit.api.command.hello.HelloPayload in project gravitee-management-rest-api by gravitee-io.

the class HelloCommandProducerTest method produce.

@Test
public void produce() {
    final InstallationEntity installationEntity = new InstallationEntity();
    installationEntity.setId(INSTALLATION_ID);
    installationEntity.getAdditionalInformation().put(CUSTOM_KEY, CUSTOM_VALUE);
    when(node.hostname()).thenReturn(HOSTNAME);
    when(installationService.getOrInitialize()).thenReturn(installationEntity);
    final HelloCommand command = new HelloCommand();
    final HelloPayload payload = new HelloPayload();
    payload.setNode(new io.gravitee.cockpit.api.command.Node());
    command.setPayload(payload);
    final TestObserver<HelloCommand> obs = cut.prepare(command).test();
    obs.awaitTerminalEvent();
    obs.assertValue(helloCommand -> {
        assertEquals(CUSTOM_VALUE, helloCommand.getPayload().getAdditionalInformation().get(CUSTOM_KEY));
        assertTrue(helloCommand.getPayload().getAdditionalInformation().containsKey("UI_URL"));
        assertTrue(helloCommand.getPayload().getAdditionalInformation().containsKey("API_URL"));
        assertEquals(HOSTNAME, helloCommand.getPayload().getNode().getHostname());
        assertEquals(GraviteeContext.getDefaultOrganization(), helloCommand.getPayload().getDefaultOrganizationId());
        assertEquals(GraviteeContext.getDefaultEnvironment(), helloCommand.getPayload().getDefaultEnvironmentId());
        assertEquals(INSTALLATION_ID, helloCommand.getPayload().getNode().getInstallationId());
        assertEquals(HOSTNAME, helloCommand.getPayload().getNode().getHostname());
        return true;
    });
}
Also used : InstallationEntity(io.gravitee.rest.api.model.InstallationEntity) HelloCommand(io.gravitee.cockpit.api.command.hello.HelloCommand) HelloPayload(io.gravitee.cockpit.api.command.hello.HelloPayload) Test(org.junit.Test)

Aggregations

HelloCommand (io.gravitee.cockpit.api.command.hello.HelloCommand)1 HelloPayload (io.gravitee.cockpit.api.command.hello.HelloPayload)1 InstallationEntity (io.gravitee.rest.api.model.InstallationEntity)1 Test (org.junit.Test)1