use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class BlueprintService method getBlueprintAndText.
public Pair<Blueprint, String> getBlueprintAndText(String blueprintName, Long workspaceId) {
User user = getLoggedInUser();
Workspace workspace = getWorkspaceService().get(workspaceId, user);
Blueprint blueprint = getByNameForWorkspaceAndLoadDefaultsIfNecessary(blueprintName, workspace);
String blueprintText = getBlueprintText(blueprintName, workspaceId);
return Pair.of(blueprint, blueprintText);
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class BlueprintService method getBlueprintText.
public String getBlueprintText(String blueprintName, Long workspaceId) {
User user = getLoggedInUser();
Workspace workspace = getWorkspaceService().get(workspaceId, user);
return getByNameForWorkspaceAndLoadDefaultsIfNecessary(blueprintName, workspace).getBlueprintText();
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class StackCreatorServiceTest method shouldThrowBadRequestWhenStackNameAlreadyExists.
@Test
public void shouldThrowBadRequestWhenStackNameAlreadyExists() {
User user = new User();
Workspace workspace = new Workspace();
workspace.setId(WORKSPACE_ID);
StackV4Request stackRequest = new StackV4Request();
stackRequest.setName(STACK_NAME);
InstanceGroupV4Request instanceGroupV4Request = new InstanceGroupV4Request();
instanceGroupV4Request.setName(INSTANCE_GROUP);
instanceGroupV4Request.setRecipeNames(Set.of(RECIPE_NAME));
stackRequest.setInstanceGroups(List.of(instanceGroupV4Request));
doNothing().when(nodeCountLimitValidator).validateProvision(any());
when(stackViewService.findByName(anyString(), anyLong())).thenReturn(Optional.of(new StackView()));
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.createStack(user, workspace, stackRequest, false));
assertThat(badRequestException).hasMessage("Cluster already exists: STACK_NAME");
verify(recipeService).get(NameOrCrn.ofName(RECIPE_NAME), WORKSPACE_ID);
verify(stackViewService).findByName(STACK_NAME, WORKSPACE_ID);
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class ClusterCreationEnvironmentValidatorTest method getStack.
private Stack getStack() {
Stack stack = new Stack();
stack.setRegion("region1");
stack.setCloudPlatform("aws");
Workspace workspace = new Workspace();
workspace.setId(1L);
Tenant tenant = new Tenant();
tenant.setName("test-tenant-name");
workspace.setTenant(tenant);
stack.setWorkspace(workspace);
stack.setEnvironmentCrn("");
return stack;
}
use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.
the class RecipeServiceTest method testCreateWithInternalUser.
@Test
public void testCreateWithInternalUser() {
Recipe recipe = getRecipe();
recipe.setCreator(null);
Workspace workspace = new Workspace();
workspace.setId(1L);
when(workspaceService.getByIdWithoutAuth(any())).thenReturn(workspace);
when(recipeRepository.save(any())).thenReturn(recipe);
Recipe savedRecipe = underTest.createWithInternalUser(recipe, 1L, "account_id");
assertThat(recipe.getCreator(), nullValue());
assertTrue(recipe.getResourceCrn().matches("crn:cdp:datahub:us-west-1:account_id:recipe:.*"));
assertEquals(workspace, savedRecipe.getWorkspace());
assertEquals(CreationType.SERVICE, savedRecipe.getCreationType());
}
Aggregations