use of org.guvnor.common.services.shared.metadata.model.Metadata in project kie-wb-common by kiegroup.
the class ProjectDiagramServiceImplTest method testSave.
@Test
public void testSave() {
Metadata metadata = mock(Metadata.class);
String comment = "COMMENT";
Map<String, Object> attributes = new HashMap<>();
CommentedOption options = mock(CommentedOption.class);
when(metadataService.setUpAttributes(path, metadata)).thenReturn(attributes);
when(commentedOptionFactory.makeCommentedOption(comment)).thenReturn(options);
when(diagramServiceController.save(path, diagram, attributes, options)).thenReturn(resultPath);
Path result = diagramService.save(path, diagram, metadata, comment);
verify(diagramServiceController, times(1)).save(path, diagram, attributes, options);
assertEquals(resultPath, result);
}
use of org.guvnor.common.services.shared.metadata.model.Metadata in project kie-wb-common by kiegroup.
the class PackageNameWhiteListSaverTest method testSave.
@Test
public void testSave() throws Exception {
final Path path = testFileSystem.createTempFile("whitelist");
final WhiteList whiteList = new WhiteList();
whiteList.add("org.drools");
whiteList.add("org.guvnor");
final Metadata metadata = new Metadata();
final String comment = "comment";
final HashMap<String, Object> attributes = new HashMap<String, Object>();
when(metadataService.setUpAttributes(path, metadata)).thenReturn(attributes);
final CommentedOption commentedOption = mock(CommentedOption.class);
when(commentedOptionFactory.makeCommentedOption("comment")).thenReturn(commentedOption);
saver.save(path, whiteList, metadata, comment);
ArgumentCaptor<String> whiteListTextArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(ioService).write(any(org.uberfire.java.nio.file.Path.class), whiteListTextArgumentCaptor.capture(), eq(attributes), eq(commentedOption));
final String whiteListAsText = whiteListTextArgumentCaptor.getValue();
assertTrue(whiteListAsText.contains("org.drools"));
assertTrue(whiteListAsText.contains("org.guvnor"));
}
use of org.guvnor.common.services.shared.metadata.model.Metadata in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorServiceImpl method save.
@Override
public Path save(final Path path, final GuidedDecisionTableEditorGraphModel model, final Metadata metadata, final String comment) {
try {
final Metadata currentMetadata = metadataService.getMetadata(path);
versionEntriesPaths(model);
ioService.write(Paths.convert(path), GuidedDTGraphXMLPersistence.getInstance().marshal(model), metadataService.setUpAttributes(path, metadata), commentedOptionFactory.makeCommentedOption(comment));
fireMetadataSocialEvents(path, currentMetadata, metadata);
return path;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.shared.metadata.model.Metadata in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorServiceImplTest method checkSave.
@Test
@SuppressWarnings("unchecked")
public void checkSave() {
final Path path = mock(Path.class);
final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel();
final Metadata metadata = mock(Metadata.class);
final String comment = "comment";
when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix());
service.save(path, model, metadata, comment);
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(Map.class), any(CommentedOption.class));
}
use of org.guvnor.common.services.shared.metadata.model.Metadata in project drools-wb by kiegroup.
the class BaseGuidedDecisionTablePresenterTest method makeDecisionTableContent.
protected GuidedDecisionTableEditorContent makeDecisionTableContent(final int hashCode) {
final GuidedDecisionTable52 model = new GuidedDecisionTable52() {
@Override
public int hashCode() {
return hashCode;
}
@Override
public boolean equals(Object o) {
return super.equals(o);
}
};
final Overview overview = mock(Overview.class);
final Metadata metadata = mock(Metadata.class);
when(overview.getMetadata()).thenReturn(metadata);
return new GuidedDecisionTableEditorContent(model, Collections.<PortableWorkDefinition>emptySet(), overview, mock(PackageDataModelOracleBaselinePayload.class));
}
Aggregations