use of org.kie.workbench.common.dmn.api.DMNContentResource in project kie-wb-common by kiegroup.
the class DMNContentServiceImpl method getProjectContent.
@Override
public DMNContentResource getProjectContent(final Path path, final String defSetId) {
final String content = getSource(path);
final String title = path.getFileName();
final ProjectMetadata metadata = buildMetadataInstance(path, defSetId, title);
return new DMNContentResource(content, metadata);
}
use of org.kie.workbench.common.dmn.api.DMNContentResource in project kie-wb-common by kiegroup.
the class DMNClientProjectDiagramServiceTest method testGetMarshallerCallback.
@Test
public void testGetMarshallerCallback() {
final DMNContentResource resource = mock(DMNContentResource.class);
final Diagram diagram = mock(Diagram.class);
final Graph graph = mock(Graph.class);
final ProjectMetadata projectMetadata = mock(ProjectMetadata.class);
final String name = "name";
when(diagram.getName()).thenReturn(name);
when(diagram.getGraph()).thenReturn(graph);
when(resource.getMetadata()).thenReturn(projectMetadata);
service.getMarshallerCallback(resource, projectDiagramCallback).onSuccess(diagram);
verify(projectDiagramCallback).onSuccess(projectDiagramArgumentCaptor.capture());
final ProjectDiagramImpl projectDiagram = projectDiagramArgumentCaptor.getValue();
assertEquals(name, projectDiagram.getName());
assertEquals(graph, projectDiagram.getGraph());
assertEquals(projectMetadata, projectDiagram.getMetadata());
}
use of org.kie.workbench.common.dmn.api.DMNContentResource in project kie-wb-common by kiegroup.
the class DMNClientProjectDiagramServiceTest method testAsProjectDiagramImpl.
@Test
public void testAsProjectDiagramImpl() {
final Graph graph = mock(Graph.class);
final Diagram diagram = mock(Diagram.class);
final DMNContentResource resource = mock(DMNContentResource.class);
final ProjectMetadata metadata = mock(ProjectMetadata.class);
when(diagram.getName()).thenReturn("Traffic Violation.dmn");
when(diagram.getGraph()).thenReturn(graph);
when(resource.getMetadata()).thenReturn(metadata);
final ProjectDiagramImpl projectDiagram = service.asProjectDiagramImpl(diagram, resource);
assertEquals("Traffic Violation", projectDiagram.getName());
assertEquals(graph, projectDiagram.getGraph());
assertEquals(metadata, projectDiagram.getMetadata());
}
use of org.kie.workbench.common.dmn.api.DMNContentResource in project kie-wb-common by kiegroup.
the class DMNContentServiceImplTest method testGetProjectContent.
@Test
public void testGetProjectContent() {
final String defSetId = "defSetId";
final String expectedContent = "<xml/>";
final String moduleName = "moduleName";
final Package aPackage = mock(Package.class);
final KieModule kieModule = mock(KieModule.class);
final Overview overview = mock(Overview.class);
doReturn(expectedContent).when(service).getSource(path);
when(moduleService.resolvePackage(path)).thenReturn(aPackage);
when(moduleService.resolveModule(path)).thenReturn(kieModule);
when(overviewLoader.loadOverview(path)).thenReturn(overview);
when(kieModule.getModuleName()).thenReturn(moduleName);
final DMNContentResource contentResource = service.getProjectContent(path, defSetId);
final String actualContent = contentResource.getContent();
final ProjectMetadataImpl metadata = (ProjectMetadataImpl) contentResource.getMetadata();
assertEquals(expectedContent, actualContent);
assertEquals(defSetId, metadata.getDefinitionSetId());
assertEquals(moduleName, metadata.getModuleName());
assertEquals(aPackage, metadata.getProjectPackage());
assertEquals(overview, metadata.getOverview());
assertEquals(fileName, metadata.getTitle());
assertEquals(path, metadata.getPath());
}
use of org.kie.workbench.common.dmn.api.DMNContentResource in project kie-wb-common by kiegroup.
the class DMNClientProjectDiagramServiceTest method testOnProjectContent.
@Test
public void testOnProjectContent() {
final DMNContentResource resource = mock(DMNContentResource.class);
final Metadata metadata = mock(Metadata.class);
final String content = "<dmn />";
when(resource.getMetadata()).thenReturn(metadata);
when(resource.getContent()).thenReturn(content);
doReturn(diagramCallback).when(service).getMarshallerCallback(resource, projectDiagramCallback);
service.onProjectContent(projectDiagramCallback).callback(resource);
verify(dmnMarshallerService).unmarshall(metadata, content, diagramCallback);
}
Aggregations