@Override public Graph unmarshall(Metadata metadata, InputStream inputStream) { Graph result = super.unmarshall(metadata, inputStream); this.updateTitle(metadata, result); return result; }
@Override public String marshall(Diagram diagram) { if (validateDiagram(diagram)) { return super.marshall(diagram); } else { throw new RuntimeException("Invalid definition for Case Modeler diagram."); } }
@Test public void testMarshall_validateId() throws Exception { final Diagram mockDiagram = mockDiagram("mockName", null); exceptionRule.expect(RuntimeException.class); marshaller.marshall(mockDiagram); }
@Before public void setup() { this.marshaller = new CaseManagementDiagramMarshaller(diagramMetadataMarshaller, graphBuilderFactory, definitionManager, indexBuilder, oryxManager, factoryManager, null, // TODO! rulesManager, graphCommandManager, commandFactory); }
@Test public void testCreateBpmn2Marshaller() throws Exception { final Bpmn2Marshaller bpmn2Marshaller = this.marshaller.createBpmn2Marshaller(mock(DefinitionManager.class), mock(OryxManager.class)); assertTrue(bpmn2Marshaller instanceof CaseManagementMarshaller); }
@Test public void testCreateBpmn2UnMarshaller() throws Exception { final Bpmn2UnMarshaller bpmn2UnMarshaller = this.marshaller.createBpmn2UnMarshaller(mock(GraphObjectBuilderFactory.class), mock(DefinitionManager.class), mock(FactoryManager.class), mock(DefinitionsCacheRegistry.class), mock(RuleManager.class), mock(OryxManager.class), mock(GraphCommandManager.class), mock(GraphCommandFactory.class), mock(GraphIndexBuilder.class), Object.class, CaseManagementDiagram.class); assertTrue(bpmn2UnMarshaller instanceof CaseManagementUnMarshaller); } }
@Test public void getDiagramDefinitionSetClass() { // It is important that CaseManagementDiagramMarshaller declares it relates to the CaseManagementDefinitionSet // otherwise all sorts of things break. This test attempts to drawer the importance of this to future changes // should someone decide to change the apparent innocuous method in CaseManagementDiagramMarshaller. assertEquals(CaseManagementDefinitionSet.class, marshaller.getDiagramDefinitionSetClass()); }
@Test public void testMarshall_validateName() throws Exception { final Diagram mockDiagram = mockDiagram(null, "mockId"); exceptionRule.expect(RuntimeException.class); marshaller.marshall(mockDiagram); }
@Test public void testUpdateTitle() throws Exception { final String name = "mockName"; final Diagram mockDiagram = mockDiagram(name, null); final Metadata metadata = new MetadataImpl(); marshaller.updateTitle(metadata, mockDiagram.getGraph()); assertEquals(metadata.getTitle(), name); }