Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
TEIITOOLS-474 (cntd)
Browse files Browse the repository at this point in the history
 * commented out view definition changes due to test failures
  • Loading branch information
blafond committed Aug 2, 2018
2 parents 7937cab + 9281f49 commit 7a6957a
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ public Response stashViewEditorState(final @Context HttpHeaders headers,

// viewEditorState.setViewDefinition(uow, newViewDef);


final RestViewEditorState entity = new RestViewEditorState(uriInfo.getBaseUri(), viewEditorState, uow);
return commit(uow, mediaTypes, entity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,90 @@ public void shouldEditViewDefinitionViewEditorState() throws Exception {
}
}
*/
@Test
public void shouldEditViewDefinitionViewEditorState() throws Exception {
final URI baseUri = new URI("baseUri");
final String viewDefName = "testView";
final String desc = "test view description text";
final boolean isComplete = true;
final String sourcePath1 = "path/to/source1";
final String sourcePath2 = "path/to/source2";
final String[] sourcePaths = {sourcePath1, sourcePath2};
final String compName = "sqlComp";
final String compDesc = "description for comp1";
final String leftSrc = "path/to/source1";
final String rightSrc = "path/to/source2";
final String leftCol = "column1";
final String rightCol = "column2";
final String type = "INNER_JOIN";
final String operator = "EQ";

// put
URI uri = UriBuilder.fromUri(uriBuilder().baseUri())
.path(V1Constants.SERVICE_SEGMENT)
.path(V1Constants.USER_PROFILE)
.path(V1Constants.VIEW_EDITOR_STATE).build();

RestStateCommand undo = new RestStateCommand();
undo.setId(undoRedoId);
undo.addArgument(oldNameKey, viewName);
undo.addArgument(newNameKey, untitledName);

RestStateCommand redo = new RestStateCommand();
redo.setId(undoRedoId);
redo.addArgument(oldNameKey, untitledName);
redo.addArgument(newNameKey, viewName);

RestStateCommandAggregate command = new RestStateCommandAggregate();
command.setUndo(undo);
command.setRedo(redo);

RestStateCommandAggregate[] content = { command };

RestViewEditorState restViewEditorState = new RestViewEditorState();
restViewEditorState.setBaseUri(uriBuilder().baseUri());
restViewEditorState.setId(viewName);
restViewEditorState.setCommands(content);

RestViewDefinition def = new RestViewDefinition();
def.setBaseUri(baseUri);
def.setViewName(viewDefName);
def.setDescription(desc);
def.setComplete(isComplete);
def.setSourcePaths(sourcePaths);
RestSqlComposition sqlComp =
new RestSqlComposition(compName, compDesc, leftSrc, rightSrc, leftCol, rightCol, type, operator);
RestSqlComposition[] comps = {sqlComp};

def.setSqlCompositions(comps);

restViewEditorState.setViewDefinition(def);

try {
HttpPut request = jsonRequest(uri, RequestType.PUT);
addHeader(request, CorsHeaders.ORIGIN, "http://localhost:2772");
addHeader(request, HttpHeaders.AUTHORIZATION, AUTH_HEADER_VALUE);
addBody(request, restViewEditorState);
HttpResponse response = executeOk(request);
String entity = extractResponse(response);

RestViewEditorState restState = KomodoJsonMarshaller.unmarshall(entity, RestViewEditorState.class);
assertEquals(viewName, restState.getId());
assertEquals(restViewEditorState, restState);

assertEquals(sourcePaths, restState.getViewDefinition().getSourcePaths());
assertEquals(isComplete, restState.getViewDefinition().isComplete());
} finally {
serviceTestUtilities.removeViewEditorState(USER_NAME, viewName);
}
}

@Test
public void shouldReplaceEditorStateIfExists() throws Exception {
final String vdbName = "MyVdb";
final String modelName = "MyModel";
final String viewName = "MyView";

final String editorStateId = KomodoVdbService.getViewEditorStateId( vdbName, viewName );

{ // Add view definition info
Expand Down

0 comments on commit 7a6957a

Please sign in to comment.