assertNotNull(outRoot.getMetaData()); MetaDataType outMetadataType = outRoot.getMetaData(); assertEquals(outMetadataType.getName(), "testvalue"); assertEquals(outMetadataType.getMetaValue(), "testentry");
public static String getMetaDataValue(List<ExtensionAttributeValue> extensionValues, String metaDataName) { if (extensionValues != null && extensionValues.size() > 0) { for (ExtensionAttributeValue extattrval : extensionValues) { FeatureMap extensionElements = extattrval.getValue(); List<MetaDataType> metadataExtensions = (List<MetaDataType>) extensionElements .get(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, true); for (MetaDataType metaType : metadataExtensions) { if (metaType.getName() != null && metaType.getName().equals(metaDataName) && metaType.getMetaValue() != null && metaType.getMetaValue().length() > 0) { return metaType.getMetaValue(); } } } } return null; }
private void prepareExtensionElement(String extensionElementName, String value) { ExtensionAttributeValue extensionAttributeValue = mock(ExtensionAttributeValue.class); FeatureMap extensionElements = mock(FeatureMap.class); when(extensionAttributeValue.getValue()).thenReturn(extensionElements); List<MetaDataType> metadataExtensions = new ArrayList<>(); MetaDataType metaDataType = mock(MetaDataType.class); when(metaDataType.getName()).thenReturn(extensionElementName); when(metaDataType.getMetaValue()).thenReturn(value); metadataExtensions.add(metaDataType); when(extensionElements.get(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, true)).thenReturn(metadataExtensions); List<ExtensionAttributeValue> extensionAttributes = new ArrayList<>(); extensionAttributes.add(extensionAttributeValue); when(baseElement.getExtensionValues()).thenReturn(extensionAttributes); }
@Test public void testMarshallNode_CaseReusableSubprocess() throws Exception { expectedStencil = "CaseReusableSubprocess"; final MetaDataType metaDataType = mock(MetaDataType.class); when(metaDataType.getName()).thenReturn("case"); when(metaDataType.getMetaValue()).thenReturn("true"); final FeatureMap featureMap = mock(FeatureMap.class); when(featureMap.get(eq(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA), eq(true))) .thenReturn(Collections.singletonList(metaDataType)); final ExtensionAttributeValue extensionAttributeValue = mock(ExtensionAttributeValue.class); when(extensionAttributeValue.getValue()).thenReturn(featureMap); final CallActivity callActivity = mock(CallActivity.class); when(callActivity.getExtensionValues()).thenReturn(Collections.singletonList(extensionAttributeValue)); tested.marshallNode(callActivity, new HashMap<>(), "ReusableSubprocess", mock(BPMNPlane.class), mock(JsonGenerator.class), 0.0f, 0.0f); }
@Test public void testMarshallNode_ProcessReusableSubprocess() throws Exception { expectedStencil = "ProcessReusableSubprocess"; final MetaDataType metaDataType = mock(MetaDataType.class); when(metaDataType.getName()).thenReturn("case"); when(metaDataType.getMetaValue()).thenReturn("false"); final FeatureMap featureMap = mock(FeatureMap.class); when(featureMap.get(eq(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA), eq(true))) .thenReturn(Collections.singletonList(metaDataType)); final ExtensionAttributeValue extensionAttributeValue = mock(ExtensionAttributeValue.class); when(extensionAttributeValue.getValue()).thenReturn(featureMap); final CallActivity callActivity = mock(CallActivity.class); when(callActivity.getExtensionValues()).thenReturn(Collections.singletonList(extensionAttributeValue)); tested.marshallNode(callActivity, new HashMap<>(), "ReusableSubprocess", mock(BPMNPlane.class), mock(JsonGenerator.class), 0.0f, 0.0f); } }
@Test public void testApplyCallActivityProperties() throws Exception { final CallActivity callActivity = mock(CallActivity.class); when(callActivity.getExtensionValues()).thenReturn(new ArrayList<>()); final String propertyName = "isCase"; final String propertyValue = "true"; final String resultName = "case"; final String resultValue = "<![CDATA[" + propertyValue + "]]>"; final Map<String, String> properties = new HashMap<>(); properties.put(propertyName, propertyValue); tested.applyCallActivityProperties(callActivity, properties); assertFalse(callActivity.getExtensionValues().isEmpty()); final ExtensionAttributeValue extenstionValue = callActivity.getExtensionValues().get(0); final Optional<String> value = extenstionValue.getValue().stream() .filter(v -> resultName.equals(((MetaDataType) v.getValue()).getName())) .map(v -> ((MetaDataType) v.getValue()).getMetaValue()).findAny(); assertTrue(value.isPresent() && resultValue.equals(value.get())); }
private String getProcessExtensionValue(Process process, String propertyName) { List<ExtensionAttributeValue> extensionValues = process.getExtensionValues(); for (ExtensionAttributeValue extensionValue : extensionValues) { FeatureMap featureMap = extensionValue.getValue(); for (int i = 0; i < featureMap.size(); i++) { EStructuralFeatureImpl.SimpleFeatureMapEntry featureMapEntry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) featureMap.get(i); MetaDataType featureMapValue = (MetaDataType) featureMapEntry.getValue(); if (propertyName.equals(featureMapValue.getName())) { return featureMapValue.getMetaValue(); } } } return ""; }
private String getProcessExtensionValue(Process process, String propertyName) { List<ExtensionAttributeValue> extensionValues = process.getExtensionValues(); for (ExtensionAttributeValue extensionValue : extensionValues) { FeatureMap featureMap = extensionValue.getValue(); for (int i = 0; i < featureMap.size(); i++) { EStructuralFeatureImpl.SimpleFeatureMapEntry featureMapEntry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) featureMap.get(i); MetaDataType featureMapValue = (MetaDataType) featureMapEntry.getValue(); if (propertyName.equals(featureMapValue.getName())) { return featureMapValue.getMetaValue(); } } } return ""; }