Search in sources :

Example 1 with DMNContentResource

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);
}
Also used : ProjectMetadata(org.kie.workbench.common.stunner.project.diagram.ProjectMetadata) DMNContentResource(org.kie.workbench.common.dmn.api.DMNContentResource)

Example 2 with DMNContentResource

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());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ProjectMetadata(org.kie.workbench.common.stunner.project.diagram.ProjectMetadata) DMNContentResource(org.kie.workbench.common.dmn.api.DMNContentResource) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) ProjectDiagramImpl(org.kie.workbench.common.stunner.project.diagram.impl.ProjectDiagramImpl) Test(org.junit.Test)

Example 3 with DMNContentResource

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());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ProjectMetadata(org.kie.workbench.common.stunner.project.diagram.ProjectMetadata) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) DMNContentResource(org.kie.workbench.common.dmn.api.DMNContentResource) ProjectDiagramImpl(org.kie.workbench.common.stunner.project.diagram.impl.ProjectDiagramImpl) Test(org.junit.Test)

Example 4 with DMNContentResource

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());
}
Also used : Overview(org.guvnor.common.services.shared.metadata.model.Overview) Package(org.guvnor.common.services.project.model.Package) ProjectMetadataImpl(org.kie.workbench.common.stunner.project.diagram.impl.ProjectMetadataImpl) KieModule(org.kie.workbench.common.services.shared.project.KieModule) DMNContentResource(org.kie.workbench.common.dmn.api.DMNContentResource) Test(org.junit.Test)

Example 5 with DMNContentResource

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);
}
Also used : ProjectMetadata(org.kie.workbench.common.stunner.project.diagram.ProjectMetadata) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) DMNContentResource(org.kie.workbench.common.dmn.api.DMNContentResource) Test(org.junit.Test)

Aggregations

DMNContentResource (org.kie.workbench.common.dmn.api.DMNContentResource)5 Test (org.junit.Test)4 ProjectMetadata (org.kie.workbench.common.stunner.project.diagram.ProjectMetadata)4 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)2 Graph (org.kie.workbench.common.stunner.core.graph.Graph)2 ProjectDiagram (org.kie.workbench.common.stunner.project.diagram.ProjectDiagram)2 ProjectDiagramImpl (org.kie.workbench.common.stunner.project.diagram.impl.ProjectDiagramImpl)2 Package (org.guvnor.common.services.project.model.Package)1 Overview (org.guvnor.common.services.shared.metadata.model.Overview)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)1 ProjectMetadataImpl (org.kie.workbench.common.stunner.project.diagram.impl.ProjectMetadataImpl)1