use of org.kie.dmn.model.v1_4.TInformationItem in project kie-wb-common by kiegroup.
the class FunctionDefinitionPropertyConverterTest method doTestWBFromDMNWithContextEntry.
private void doTestWBFromDMNWithContextEntry(final FunctionKind kind, final String variableName, final Class<? extends IsLiteralExpression> literalExpressionClass) {
final org.kie.dmn.model.api.FunctionDefinition dmn = new TFunctionDefinition();
final org.kie.dmn.model.api.Context contextExpression = new TContext();
final org.kie.dmn.model.api.ContextEntry contextEntry = new TContextEntry();
final org.kie.dmn.model.api.InformationItem variable = new TInformationItem();
variable.setName(variableName);
contextEntry.setVariable(variable);
contextEntry.setExpression(new TLiteralExpression());
contextExpression.getContextEntry().add(contextEntry);
dmn.setKind(kind);
dmn.setExpression(contextExpression);
final FunctionDefinition wb = FunctionDefinitionPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
assertThat(wb.getExpression()).isInstanceOf(Context.class);
assertThat(((Context) wb.getExpression()).getContextEntry().get(0).getExpression()).isInstanceOf(literalExpressionClass);
}
use of org.kie.dmn.model.v1_4.TInformationItem in project kie-wb-common by kiegroup.
the class InformationItemPrimaryPropertyConverterTest method testDmnFromWBWhenWBIsNotNull.
@Test
public void testDmnFromWBWhenWBIsNotNull() {
final String expectedId = "id";
final String expectedName = "name";
final Id id = new Id(expectedId);
final Name name = new Name(expectedName);
final String qNameNamespaceURI = "qName namespaceURI";
final String qNameLocalPart = "qName local part";
final String qNamePrefix = "qName prefix";
final InformationItemPrimary wb = mock(InformationItemPrimary.class);
final QName qName = mock(QName.class);
final javax.xml.namespace.QName expectedQName = new javax.xml.namespace.QName(qNameNamespaceURI, qNameLocalPart, qNamePrefix);
final NamedElement parentElement = mock(NamedElement.class);
when(wb.getId()).thenReturn(id);
when(wb.getName()).thenReturn(name);
when(wb.getTypeRef()).thenReturn(qName);
when(wb.getParent()).thenReturn(parentElement);
when(parentElement.getName()).thenReturn(name);
when(qName.getNamespaceURI()).thenReturn(qNameNamespaceURI);
when(qName.getLocalPart()).thenReturn(qNameLocalPart);
when(qName.getPrefix()).thenReturn(qNamePrefix);
final TInformationItem informationItem = InformationItemPrimaryPropertyConverter.dmnFromWB(wb, wb);
final String actualId = informationItem.getId();
final String actualName = informationItem.getName();
final javax.xml.namespace.QName actualQName = informationItem.getTypeRef();
assertEquals(expectedId, actualId);
assertEquals(expectedName, actualName);
assertEquals(expectedQName, actualQName);
}
use of org.kie.dmn.model.v1_4.TInformationItem in project kie-wb-common by kiegroup.
the class InputDataConverterTest method testWBFromDMN.
@Test
@SuppressWarnings("unchecked")
public void testWBFromDMN() {
final Node<View<InputData>, ?> factoryNode = new NodeImpl<>(UUID.uuid());
final View<InputData> view = new ViewImpl<>(new InputData(), Bounds.create());
factoryNode.setContent(view);
when(factoryManager.newElement(Mockito.<String>any(), eq(getDefinitionId(InputData.class)))).thenReturn(element);
when(element.asNode()).thenReturn(factoryNode);
final org.kie.dmn.model.api.InputData dmn = new TInputData();
final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
dmn.setId(INPUT_DATA_UUID);
dmn.setName(INPUT_DATA_NAME);
dmn.setDescription(INPUT_DATA_DESCRIPTION);
dmn.setVariable(informationItem);
final Node<View<InputData>, ?> node = converter.nodeFromDMN(dmn, hasComponentWidthsConsumer);
final InputData wb = (InputData) DefinitionUtils.getElementDefinition(node);
assertThat(wb).isNotNull();
assertThat(wb.getId()).isNotNull();
assertThat(wb.getId().getValue()).isEqualTo(INPUT_DATA_UUID);
assertThat(wb.getName()).isNotNull();
assertThat(wb.getName().getValue()).isEqualTo(INPUT_DATA_NAME);
assertThat(wb.getDescription()).isNotNull();
assertThat(wb.getDescription().getValue()).isEqualTo(INPUT_DATA_DESCRIPTION);
assertThat(wb.getVariable()).isNotNull();
assertThat(wb.getVariable().getName().getValue()).isEqualTo(INPUT_DATA_NAME);
verifyNoMoreInteractions(hasComponentWidthsConsumer);
}
use of org.kie.dmn.model.v1_4.TInformationItem in project kie-wb-common by kiegroup.
the class DecisionServiceConverterTest method testWBFromDMN.
@Test
@SuppressWarnings("unchecked")
public void testWBFromDMN() {
final Node<View<DecisionService>, ?> factoryNode = new NodeImpl<>(UUID.uuid());
final View<DecisionService> view = new ViewImpl<>(new DecisionService(), Bounds.create());
factoryNode.setContent(view);
when(factoryManager.newElement(Mockito.<String>any(), eq(getDefinitionId(DecisionService.class)))).thenReturn(element);
when(element.asNode()).thenReturn(factoryNode);
final org.kie.dmn.model.api.DecisionService dmn = new TDecisionService();
final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
dmn.setId(DECISION_SERVICE_UUID);
dmn.setName(DECISION_SERVICE_NAME);
dmn.setDescription(DECISION_SERVICE_DESCRIPTION);
dmn.setVariable(informationItem);
final Node<View<DecisionService>, ?> node = converter.nodeFromDMN(dmn, hasComponentWidthsConsumer);
final DecisionService wb = (DecisionService) DefinitionUtils.getElementDefinition(node);
assertThat(wb).isNotNull();
assertThat(wb.getId()).isNotNull();
assertThat(wb.getId().getValue()).isEqualTo(DECISION_SERVICE_UUID);
assertThat(wb.getName()).isNotNull();
assertThat(wb.getName().getValue()).isEqualTo(DECISION_SERVICE_NAME);
assertThat(wb.getDescription()).isNotNull();
assertThat(wb.getDescription().getValue()).isEqualTo(DECISION_SERVICE_DESCRIPTION);
assertThat(wb.getVariable()).isNotNull();
assertThat(wb.getVariable().getName().getValue()).isEqualTo(DECISION_SERVICE_NAME);
verifyNoMoreInteractions(hasComponentWidthsConsumer);
}
use of org.kie.dmn.model.v1_4.TInformationItem in project kie-wb-common by kiegroup.
the class BindingPropertyConverterTest method testWBFromDMN.
@Test
public void testWBFromDMN() {
final org.kie.dmn.model.api.Binding dmn = new TBinding();
final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
dmn.setParameter(informationItem);
final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
literalExpression.setId(EXPRESSION_UUID);
dmn.setExpression(literalExpression);
final Binding wb = BindingPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
assertThat(wb).isNotNull();
assertThat(wb.getParameter()).isNotNull();
assertThat(wb.getExpression()).isNotNull();
assertThat(wb.getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
assertThat(hasComponentWidths).isNotNull();
assertThat(hasComponentWidths).isEqualTo(wb.getExpression());
}
Aggregations