Search in sources :

Example 26 with NameOrCrn

use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.

the class EnvironmentServiceDecoratorTest method testPrepareEnvironmentsAndCredentialNameWhenEnvironmentCrnProvidedThenShouldCallGetEnvironmentByCrn.

@Test
void testPrepareEnvironmentsAndCredentialNameWhenEnvironmentCrnProvidedThenShouldCallGetEnvironmentByCrn() {
    DetailedEnvironmentResponse detailedEnvironmentResponse = mock(DetailedEnvironmentResponse.class);
    CredentialResponse credentialResponse = mock(CredentialResponse.class);
    NameOrCrn nameOrCrn = mock(NameOrCrn.class);
    Set<StackViewV4Response> stackViewResponses = Set.of(new StackViewV4Response());
    when(nameOrCrn.hasCrn()).thenReturn(true);
    when(nameOrCrn.getCrn()).thenReturn("crn");
    when(detailedEnvironmentResponse.getCredential()).thenReturn(credentialResponse);
    when(credentialResponse.getName()).thenReturn("credential-name");
    when(detailedEnvironmentResponse.getName()).thenReturn("env-name");
    when(environmentClientService.getByCrn(any())).thenReturn(detailedEnvironmentResponse);
    underTest.prepareEnvironmentsAndCredentialName(stackViewResponses, nameOrCrn);
    verify(environmentClientService, times(1)).getByCrn(any());
    assertEquals(stackViewResponses.iterator().next().getEnvironmentName(), "env-name");
    assertEquals(stackViewResponses.iterator().next().getCredentialName(), "credential-name");
    assertEquals(stackViewResponses.iterator().next().isGovCloud(), false);
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) Test(org.junit.jupiter.api.Test)

Example 27 with NameOrCrn

use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.

the class EnvironmentServiceDecoratorTest method testPrepareEnvironmentsAndCredentialWithoutNameAndCrnWhenNameProvidedThenShouldCallGetEnvironmentList.

@Test
void testPrepareEnvironmentsAndCredentialWithoutNameAndCrnWhenNameProvidedThenShouldCallGetEnvironmentList() {
    SimpleEnvironmentResponses simpleEnvironmentResponses = new SimpleEnvironmentResponses();
    SimpleEnvironmentResponse simpleEnvironmentResponse = new SimpleEnvironmentResponse();
    CredentialViewResponse credentialViewResponse = new CredentialViewResponse();
    NameOrCrn nameOrCrn = mock(NameOrCrn.class);
    StackViewV4Response stackViewV4Response = new StackViewV4Response();
    stackViewV4Response.setEnvironmentCrn("env-crn");
    Set<StackViewV4Response> stackViewResponses = Set.of(stackViewV4Response);
    when(nameOrCrn.hasCrn()).thenReturn(false);
    when(nameOrCrn.hasName()).thenReturn(false);
    credentialViewResponse.setName("credential-name");
    simpleEnvironmentResponse.setCredential(credentialViewResponse);
    simpleEnvironmentResponse.setName("env-name");
    simpleEnvironmentResponse.setCrn("env-crn");
    simpleEnvironmentResponses.setResponses(Set.of(simpleEnvironmentResponse));
    when(environmentClientService.list()).thenReturn(simpleEnvironmentResponses);
    underTest.prepareEnvironmentsAndCredentialName(stackViewResponses, nameOrCrn);
    verify(environmentClientService, times(1)).list();
    assertEquals(stackViewResponses.iterator().next().getEnvironmentName(), "env-name");
    assertEquals(stackViewResponses.iterator().next().getCredentialName(), "credential-name");
    assertEquals(stackViewResponses.iterator().next().isGovCloud(), false);
}
Also used : CredentialViewResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse) StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) SimpleEnvironmentResponses(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponses) SimpleEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) Test(org.junit.jupiter.api.Test)

Example 28 with NameOrCrn

use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.

the class EnvironmentServiceDecoratorTest method testPrepareEnvironmentsAndCredentialEnvironmentNameWhenNameProvidedThenShouldCallGetEnvironmentByName.

@Test
void testPrepareEnvironmentsAndCredentialEnvironmentNameWhenNameProvidedThenShouldCallGetEnvironmentByName() {
    DetailedEnvironmentResponse detailedEnvironmentResponse = mock(DetailedEnvironmentResponse.class);
    CredentialResponse credentialResponse = mock(CredentialResponse.class);
    NameOrCrn nameOrCrn = mock(NameOrCrn.class);
    Set<StackViewV4Response> stackViewResponses = Set.of(new StackViewV4Response());
    when(nameOrCrn.hasCrn()).thenReturn(false);
    when(nameOrCrn.hasName()).thenReturn(true);
    when(nameOrCrn.getName()).thenReturn("name");
    when(detailedEnvironmentResponse.getCredential()).thenReturn(credentialResponse);
    when(credentialResponse.getName()).thenReturn("credential-name");
    when(detailedEnvironmentResponse.getName()).thenReturn("env-name");
    when(environmentClientService.getByName(any())).thenReturn(detailedEnvironmentResponse);
    underTest.prepareEnvironmentsAndCredentialName(stackViewResponses, nameOrCrn);
    verify(environmentClientService, times(1)).getByName(any());
    assertEquals(stackViewResponses.iterator().next().getEnvironmentName(), "env-name");
    assertEquals(stackViewResponses.iterator().next().getCredentialName(), "credential-name");
    assertEquals(stackViewResponses.iterator().next().isGovCloud(), false);
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) Test(org.junit.jupiter.api.Test)

Example 29 with NameOrCrn

use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.

the class StackOperationsTest method testGetWhenNameOrCrnNameFilledThenProperGetCalled.

@Test
public void testGetWhenNameOrCrnNameFilledThenProperGetCalled() {
    StackV4Response expected = stackResponse();
    NameOrCrn nameOrCrn = NameOrCrn.ofName(stack.getName());
    when(stackCommonService.findStackByNameOrCrnAndWorkspaceId(nameOrCrn, stack.getWorkspace().getId(), STACK_ENTRIES, STACK_TYPE)).thenReturn(expected);
    StackV4Response result = underTest.get(nameOrCrn, stack.getWorkspace().getId(), STACK_ENTRIES, STACK_TYPE);
    assertEquals(expected, result);
    verify(stackCommonService, times(1)).findStackByNameOrCrnAndWorkspaceId(nameOrCrn, stack.getWorkspace().getId(), STACK_ENTRIES, STACK_TYPE);
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) Test(org.junit.Test)

Example 30 with NameOrCrn

use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.

the class StackOperationsTest method testChangeImageCatalogFlowNotInProgress.

@Test
public void testChangeImageCatalogFlowNotInProgress() {
    NameOrCrn nameOrCrn = NameOrCrn.ofName(stack.getName());
    when(stackService.getByNameOrCrnInWorkspace(nameOrCrn, stack.getWorkspace().getId())).thenReturn(stack);
    when(flowLogService.isOtherFlowRunning(stack.getId())).thenReturn(false);
    underTest.changeImageCatalog(nameOrCrn, stack.getWorkspace().getId(), IMAGE_CATALOG);
    verify(stackImageService).changeImageCatalog(stack, IMAGE_CATALOG);
}
Also used : NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) Test(org.junit.Test)

Aggregations

NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)19 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)11 Test (org.junit.Test)8 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)7 Test (org.junit.jupiter.api.Test)6 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)4 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)4 UpdateStackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.UpdateStackV4Request)3 CertificatesRotationV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.CertificatesRotationV4Request)3 InternalUpgradeSettings (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings)3 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)3 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)3 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)3 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)3 InternalOnly (com.sequenceiq.authorization.annotation.InternalOnly)2 UpdateClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.UpdateClusterV4Request)2 ImageInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)2 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)2 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)2 StackImageChangeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackImageChangeV4Request)1