Search in sources :

Example 11 with Workspace

use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.

the class StackCreatorServiceTest method shouldThrowBadRequestWhenRecipeIsMissing.

@Test
public void shouldThrowBadRequestWhenRecipeIsMissing() {
    User user = new User();
    Workspace workspace = new Workspace();
    workspace.setId(WORKSPACE_ID);
    StackV4Request stackRequest = new StackV4Request();
    InstanceGroupV4Request instanceGroupV4Request = new InstanceGroupV4Request();
    instanceGroupV4Request.setName(INSTANCE_GROUP);
    instanceGroupV4Request.setRecipeNames(Set.of(RECIPE_NAME));
    stackRequest.setInstanceGroups(List.of(instanceGroupV4Request));
    doNothing().when(nodeCountLimitValidator).validateProvision(any());
    doThrow(new NotFoundException("missing recipe")).when(recipeService).get(NameOrCrn.ofName(RECIPE_NAME), WORKSPACE_ID);
    BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.createStack(user, workspace, stackRequest, false));
    assertThat(badRequestException).hasMessage("The given recipe does not exist for the instance group \"INSTANCE_GROUP\": RECIPE_NAME");
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with Workspace

use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.

the class AuditEventServiceTest method testGetEventsForUserWithTypeAndResourceIdByWorkspaceWhenResourceCrnIsNotEmpty.

@Test
public void testGetEventsForUserWithTypeAndResourceIdByWorkspaceWhenResourceCrnIsNotEmpty() {
    Workspace workspace = new Workspace();
    long resourceId = 0L;
    String resourceCrn = "crn";
    when(legacyStructuredEventDBService.findByWorkspaceAndResourceTypeAndResourceCrn(workspace, resourceCrn)).thenReturn(Collections.emptyList());
    underTest.getEventsForUserWithTypeAndResourceIdByWorkspace(workspace, null, resourceId, resourceCrn);
    verify(legacyStructuredEventDBService, never()).findByWorkspaceAndResourceTypeAndResourceId(workspace, null, resourceId);
    verify(legacyStructuredEventDBService).findByWorkspaceAndResourceTypeAndResourceCrn(workspace, resourceCrn);
}
Also used : Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Test(org.junit.Test)

Example 13 with Workspace

use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.

the class BlueprintServiceTest method testCreateWithInternalUser.

@Test
public void testCreateWithInternalUser() throws TransactionExecutionException {
    Blueprint blueprint = new Blueprint();
    blueprint.setBlueprintText("{}");
    doAnswer(invocation -> ((Supplier<Blueprint>) invocation.getArgument(0)).get()).when(transactionService).required(any(Supplier.class));
    Workspace workspace = new Workspace();
    workspace.setId(1L);
    when(workspaceService.getByIdWithoutAuth(1L)).thenReturn(workspace);
    when(blueprintRepository.save(blueprint)).thenReturn(blueprint);
    Blueprint savedBlueprint = underTest.createWithInternalUser(blueprint, 1L, ACCOUNT_ID);
    assertEquals(workspace, savedBlueprint.getWorkspace());
    assertTrue(blueprint.getResourceCrn().matches("crn:cdp:datahub:us-west-1:" + ACCOUNT_ID + ":clustertemplate:.*"));
    assertEquals(ResourceStatus.SERVICE_MANAGED, savedBlueprint.getStatus());
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Supplier(java.util.function.Supplier) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Test(org.junit.jupiter.api.Test)

Example 14 with Workspace

use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.

the class BlueprintServiceTest method getWorkspace.

private Workspace getWorkspace() {
    Workspace workspace = new Workspace();
    workspace.setId(1L);
    return workspace;
}
Also used : Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 15 with Workspace

use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.

the class ClusterCreationSetupServiceTest method init.

@Before
public void init() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException, IOException {
    MockitoAnnotations.initMocks(this);
    workspace = new Workspace();
    clusterRequest = new ClusterV4Request();
    stack = new Stack();
    stack.setId(1L);
    stack.setWorkspace(workspace);
    stack.setEnvironmentCrn("env");
    stack.setName("name");
    blueprint = new Blueprint();
    blueprint.setBlueprintText("{}");
    user = new User();
    Map<InstanceGroupType, String> userData = new HashMap<>();
    userData.put(InstanceGroupType.CORE, "userdata");
    Image image = new Image("imagename", userData, "centos7", REDHAT_7, "url", "imgcatname", "id", Collections.emptyMap());
    Component imageComponent = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json(image), stack);
    cluster = new Cluster();
    stack.setCluster(cluster);
    when(clusterDecorator.decorate(any(), any(), any(), any(), any(), any())).thenReturn(cluster);
    when(componentConfigProviderService.getAllComponentsByStackIdAndType(any(), any())).thenReturn(Sets.newHashSet(imageComponent));
    when(blueprintUtils.getBlueprintStackVersion(any())).thenReturn(HDP_VERSION);
    when(blueprintUtils.getBlueprintStackName(any())).thenReturn("HDP");
    DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(CDH_VERSION);
    when(imageBasedDefaultCDHEntries.getEntries(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(Collections.singletonMap(CDH_VERSION, new ImageBasedDefaultCDHInfo(defaultCDHInfo, Mockito.mock(com.sequenceiq.cloudbreak.cloud.model.catalog.Image.class))));
    when(componentConfigProviderService.getImage(anyLong())).thenReturn(image);
    StackMatrixV4Response stackMatrixV4Response = new StackMatrixV4Response();
    stackMatrixV4Response.setCdh(Collections.singletonMap(CDH_VERSION, null));
    when(stackMatrixService.getStackMatrix(workspace.getId(), imageCatalogPlatform(PLATFORM), IMAGE_CATALOG_NAME)).thenReturn(stackMatrixV4Response);
    when(clouderaManagerClusterCreationSetupService.prepareClouderaManagerCluster(any(), any(), any(), any(), any())).thenReturn(new ArrayList<>());
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) DefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo) RepoTestUtil.getDefaultCDHInfo(com.sequenceiq.cloudbreak.RepoTestUtil.getDefaultCDHInfo) Component(com.sequenceiq.cloudbreak.domain.stack.Component) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Before(org.junit.Before)

Aggregations

Workspace (com.sequenceiq.cloudbreak.workspace.model.Workspace)75 User (com.sequenceiq.cloudbreak.workspace.model.User)26 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)24 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)18 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)17 Tenant (com.sequenceiq.cloudbreak.workspace.model.Tenant)12 CloudbreakUser (com.sequenceiq.cloudbreak.common.user.CloudbreakUser)9 Test (org.junit.jupiter.api.Test)9 HashMap (java.util.HashMap)8 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)7 Before (org.junit.Before)7 Test (org.junit.Test)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)4 Json (com.sequenceiq.cloudbreak.common.json.Json)4 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)4 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)4 ClusterTemplate (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterTemplate)4 HashSet (java.util.HashSet)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4