Skip to content

Commit

Permalink
Add javadoc, remove the superfluous validation step.
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Krejci <lkrejci@redhat.com>
  • Loading branch information
metlos committed Jun 5, 2019
1 parent 0dfe0fe commit c0dcb0a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@ public WorkspaceImpl createWorkspace(
return workspace;
}

/**
* Creates a workspace out of a devfile.
*
* <p>The devfile should have been validated using the {@link
* DevfileIntegrityValidator#validateDevfile(Devfile)}. This method does rest of the validation
* and actually creates the workspace.
*
* @param devfile the devfile describing the workspace
* @param namespace workspace name is unique in this namespace
* @param attributes workspace instance attributes
* @return new workspace instance
* @throws NullPointerException when either {@code config} or {@code namespace} is null
* @throws NotFoundException when account with given id was not found
* @throws ConflictException when any conflict occurs (e.g Workspace with such name already exists
* for {@code owner})
* @throws ServerException when any other error occurs
* @throws ValidationException when incoming configuration or attributes are not valid
*/
@Traced
public WorkspaceImpl createWorkspace(
Devfile devfile,
Expand All @@ -140,7 +158,6 @@ public WorkspaceImpl createWorkspace(
validator.validateAttributes(attributes);

try {
devfileIntegrityValidator.validateDevfile(devfile);
devfileIntegrityValidator.validateContentReferences(devfile, contentProvider);
} catch (DevfileFormatException e) {
throw new ValidationException(e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,21 +589,6 @@ public void removesTemporaryWorkspaceAfterStartFailed() throws Exception {
verify(workspaceDao, times(1)).remove(anyString());
}

@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "boom")
public void shouldFailToCreateWorkspaceUsingInvalidDevfile() throws Exception {
// given
doThrow(new DevfileFormatException("boom"))
.when(devfileIntegrityValidator)
.validateDevfile(any());

Devfile devfile = mock(Devfile.class);

// when
workspaceManager.createWorkspace(devfile, "ns", emptyMap(), null);

// then exception is thrown
}

@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "boom")
public void shouldFailTocreateWorkspaceUsingInconsistentDevfile() throws Exception {
// given
Expand Down

0 comments on commit c0dcb0a

Please sign in to comment.