Search in sources :

Example 1 with EnvironmentService

use of io.gravitee.rest.api.service.EnvironmentService in project gravitee-management-rest-api by gravitee-io.

the class HelloCommandProducerTest method handleReplay_shouldUpdateDefaultEnvironmentCockpitId.

@Test
public void handleReplay_shouldUpdateDefaultEnvironmentCockpitId() {
    HelloReply helloReply = new HelloReply();
    helloReply.setCommandStatus(CommandStatus.SUCCEEDED);
    helloReply.setDefaultEnvironmentCockpitId("env#cockpit-1");
    String defaultEnvId = "DEFAULT";
    EnvironmentEntity defaultEnvironment = new EnvironmentEntity();
    defaultEnvironment.setId(defaultEnvId);
    defaultEnvironment.setOrganizationId("org#1");
    when(environmentService.findById(defaultEnvId)).thenReturn(defaultEnvironment);
    cut.handleReply(helloReply);
    verify(environmentService).createOrUpdate(eq(defaultEnvironment.getOrganizationId()), eq(defaultEnvId), argThat(env -> env.getCockpitId().equals("env#cockpit-1")));
}
Also used : ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) GraviteeContext(io.gravitee.rest.api.service.common.GraviteeContext) Command(io.gravitee.cockpit.api.command.Command) InstallationEntity(io.gravitee.rest.api.model.InstallationEntity) TechnicalManagementException(io.gravitee.rest.api.service.exceptions.TechnicalManagementException) Before(org.junit.Before) Node(io.gravitee.node.api.Node) OrganizationEntity(io.gravitee.rest.api.model.OrganizationEntity) HelloReply(io.gravitee.cockpit.api.command.hello.HelloReply) InstallationService(io.gravitee.rest.api.service.InstallationService) Assert.assertTrue(org.junit.Assert.assertTrue) EnvironmentService(io.gravitee.rest.api.service.EnvironmentService) TestObserver(io.reactivex.observers.TestObserver) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) OrganizationService(io.gravitee.rest.api.service.OrganizationService) EnvironmentEntity(io.gravitee.rest.api.model.EnvironmentEntity) Mockito.verify(org.mockito.Mockito.verify) HelloPayload(io.gravitee.cockpit.api.command.hello.HelloPayload) CommandStatus(io.gravitee.cockpit.api.command.CommandStatus) HelloCommand(io.gravitee.cockpit.api.command.hello.HelloCommand) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) EnvironmentEntity(io.gravitee.rest.api.model.EnvironmentEntity) HelloReply(io.gravitee.cockpit.api.command.hello.HelloReply) Test(org.junit.Test)

Aggregations

Command (io.gravitee.cockpit.api.command.Command)1 CommandStatus (io.gravitee.cockpit.api.command.CommandStatus)1 HelloCommand (io.gravitee.cockpit.api.command.hello.HelloCommand)1 HelloPayload (io.gravitee.cockpit.api.command.hello.HelloPayload)1 HelloReply (io.gravitee.cockpit.api.command.hello.HelloReply)1 Node (io.gravitee.node.api.Node)1 EnvironmentEntity (io.gravitee.rest.api.model.EnvironmentEntity)1 InstallationEntity (io.gravitee.rest.api.model.InstallationEntity)1 OrganizationEntity (io.gravitee.rest.api.model.OrganizationEntity)1 EnvironmentService (io.gravitee.rest.api.service.EnvironmentService)1 InstallationService (io.gravitee.rest.api.service.InstallationService)1 OrganizationService (io.gravitee.rest.api.service.OrganizationService)1 GraviteeContext (io.gravitee.rest.api.service.common.GraviteeContext)1 TechnicalManagementException (io.gravitee.rest.api.service.exceptions.TechnicalManagementException)1 TestObserver (io.reactivex.observers.TestObserver)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Before (org.junit.Before)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1