@Test public void testCreate() { final String diagramName = "Diagram name"; final String diagramDescription = "Diagram description"; final String image = "<image>"; final String admin = "admin"; final String currentDate = "2 January 1992"; final String namespace = ": final String expectedDroolsLogo = "droolsLogo"; final String expectedSupportedByRedHatLogo = "supportedByRedHatLogo"; final List<DRGElement> drgElements = singletonList(mock(DRGElement.class)); final ItemDefinition uuid = makeItemDefinition("tUUID", "String"); final ItemDefinition id = makeItemDefinition("id", "tUUID"); final ItemDefinition name = makeItemDefinition("name", "String"); final ItemDefinition person = makeItemDefinition("tPerson", null, id, name); final List<ItemDefinition> itemDefinitions = asList(uuid, person); final UnaryTests unaryTests = new UnaryTests(); unaryTests.setText(new Text("[1, 2, 3]")); id.setAllowedValues(unaryTests); id.setIsCollection(true); doReturn(image).when(documentationFactory).getDiagramImage(); doReturn(i18n).when(documentationFactory).getDocumentationI18n(); doReturn(moment).when(documentationFactory).moment(); when(definitions.getNamespace()).thenReturn(new Text(namespace)); when(graphUtils.getDefinitions(diagram)).thenReturn(definitions); when(definitions.getName()).thenReturn(new Name(diagramName)); when(definitions.getDescription()).thenReturn(new Description(diagramDescription)); when(graphUtils.getDRGElements(diagram)).thenReturn(drgElements); when(definitions.getItemDefinition()).thenReturn(itemDefinitions); when(sessionInfo.getIdentity()).thenReturn(user); when(user.getIdentifier()).thenReturn(admin); when(moment.format("D MMMM YYYY")).thenReturn(currentDate); final DMNDocumentation documentation = documentationFactory.create(diagram); assertEquals(namespace, documentation.getNamespace()); assertEquals(diagramName, documentation.getDiagramName()); assertEquals(diagramDescription, documentation.getDiagramDescription()); assertEquals(image, documentation.getDiagramImage()); assertEquals(admin, documentation.getCurrentUser()); assertEquals(currentDate, documentation.getCurrentDate()); assertEquals(expectedDroolsLogo, documentation.getDroolsLogoURI()); assertEquals(expectedSupportedByRedHatLogo, documentation.getSupportedByRedHatLogoURI()); assertEquals(i18n, documentation.getI18n()); assertNotNull(documentation.getModuleName()); assertNotNull(documentation.getDataTypes()); assertTrue(documentation.hasGraphNodes()); final List<DMNDocumentationDataType> dataTypes = documentation.getDataTypesList(); assertEquals(4, dataTypes.size()); assertEquals("", dataTypes.get(0).getConstraint()); assertEquals("tUUID", dataTypes.get(0).getName()); assertEquals("String", dataTypes.get(0).getType()); assertEquals("", dataTypes.get(0).getListLabel()); assertEquals(0, dataTypes.get(0).getLevel()); assertTrue(dataTypes.get(0).isTopLevel()); assertEquals("", dataTypes.get(1).getConstraint()); assertEquals("tPerson", dataTypes.get(1).getName()); assertEquals("Structure", dataTypes.get(1).getType()); assertEquals("", dataTypes.get(1).getListLabel()); assertEquals(0, dataTypes.get(1).getLevel()); assertTrue(dataTypes.get(1).isTopLevel()); assertEquals("Constraints: [1, 2, 3]", dataTypes.get(2).getConstraint()); assertEquals("id", dataTypes.get(2).getName()); assertEquals("tUUID", dataTypes.get(2).getType()); assertEquals("List: Yes", dataTypes.get(2).getListLabel()); assertEquals(1, dataTypes.get(2).getLevel()); assertFalse(dataTypes.get(2).isTopLevel()); assertEquals("", dataTypes.get(3).getConstraint()); assertEquals("name", dataTypes.get(3).getName()); assertEquals("String", dataTypes.get(3).getType()); assertEquals("", dataTypes.get(3).getListLabel()); assertEquals(1, dataTypes.get(3).getLevel()); assertFalse(dataTypes.get(3).isTopLevel()); }
public DMNDocumentation create(final Diagram diagram) { return DMNDocumentation.create(getNamespace(diagram), getDiagramName(diagram), getDiagramDescription(diagram), hasGraphNodes(diagram), getDataTypes(diagram), getDrds(diagram), getDiagramImage(), getCurrentUserName(), getCurrentDate(), getDocumentationI18n()); }
DMNDocumentationFactory { public DMNDocumentation create(final Diagram diagram) { return DMNDocumentation.create(getNamespace(diagram), getDiagramName(diagram), getDiagramDescription(diagram), hasGraphNodes(diagram), getDataTypes(diagram), getDrds(diagram), getDiagramImage(), getCurrentUserName(), getCurrentDate(), getDocumentationI18n()); } }
DMNDocumentationFactory { public DMNDocumentation create(final Diagram diagram) { return DMNDocumentation.create(getNamespace(diagram), getDiagramName(diagram), getDiagramDescription(diagram), hasGraphNodes(diagram), getDataTypes(diagram), getDrds(diagram), getDiagramImage(), getCurrentUserName(), getCurrentDate(), getDocumentationI18n()); } @Inject  DMNDocumentationFactory(final CanvasFileExport canvasFileExport,
                                   final TranslationService translationService,
                                   final DMNDocumentationDRDsFactory drdsFactory,
                                   final SessionInfo sessionInfo,
                                   final DMNGraphUtils graphUtils); }
DMNDocumentationFactory { public DMNDocumentation create(final Diagram diagram) { return DMNDocumentation.create(getNamespace(diagram), getDiagramName(diagram), getDiagramDescription(diagram), hasGraphNodes(diagram), getDataTypes(diagram), getDrds(diagram), getDiagramImage(), getCurrentUserName(), getCurrentDate(), getDocumentationI18n()); } @Inject  DMNDocumentationFactory(final CanvasFileExport canvasFileExport,
                                   final TranslationService translationService,
                                   final DMNDocumentationDRDsFactory drdsFactory,
                                   final SessionInfo sessionInfo,
                                   final DMNGraphUtils graphUtils); DMNDocumentation create(final Diagram diagram); }
DMNDocumentationFactory { public DMNDocumentation create(final Diagram diagram) { return DMNDocumentation.create(getNamespace(diagram), getDiagramName(diagram), getDiagramDescription(diagram), hasGraphNodes(diagram), getDataTypes(diagram), getDrds(diagram), getDiagramImage(), getCurrentUserName(), getCurrentDate(), getDocumentationI18n()); } @Inject  DMNDocumentationFactory(final CanvasFileExport canvasFileExport,
                                   final TranslationService translationService,
                                   final DMNDocumentationDRDsFactory drdsFactory,
                                   final SessionInfo sessionInfo,
                                   final DMNGraphUtils graphUtils); DMNDocumentation create(final Diagram diagram);  }