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");
}
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);
}
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());
}
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;
}
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<>());
}
Aggregations