use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricherTest method testModelEnrichmentWhenDecisionTypeRefIsStructureWithNoFields.
@Test
public void testModelEnrichmentWhenDecisionTypeRefIsStructureWithNoFields() {
final DMNGraphUtils dmnGraphUtils = mock(DMNGraphUtils.class);
final Definitions definitions = mock(Definitions.class);
final HasExpression hasExpression = mock(HasExpression.class);
final Decision decision = mock(Decision.class);
final InformationItemPrimary informationItemPrimary = mock(InformationItemPrimary.class);
final ItemDefinition tPerson = mock(ItemDefinition.class);
final QName tPersonTypeRef = new QName("", TYPE_PERSON);
when(tPerson.getName()).thenReturn(new Name(TYPE_PERSON));
when(tPerson.getTypeRef()).thenReturn(tPersonTypeRef);
when(tPerson.getItemComponent()).thenReturn(emptyList());
when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
when(definitions.getItemDefinition()).thenReturn(Collections.singletonList(tPerson));
when(hasExpression.asDMNModelInstrumentedBase()).thenReturn(decision);
when(decision.getVariable()).thenReturn(informationItemPrimary);
when(informationItemPrimary.getTypeRef()).thenReturn(tPersonTypeRef);
final DecisionTableEditorDefinitionEnricher enricher = new DecisionTableEditorDefinitionEnricher(null, dmnGraphUtils, itemDefinitionUtils);
final Optional<DecisionTable> oModel = definition.getModelClass();
final DecisionTable model = oModel.get();
enricher.buildOutputClausesByDataType(hasExpression, model, new DecisionRule());
final List<OutputClause> outputClauses = model.getOutput();
assertThat(outputClauses.size()).isEqualTo(1);
final OutputClause outputClause = outputClauses.get(0);
assertEquals(DEFAULT_OUTPUT_NAME, outputClause.getName());
assertEquals(tPersonTypeRef, outputClause.getTypeRef());
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class ObserverBuilderControlTest method testUpdateExpressionFromDefinition.
@Test
public void testUpdateExpressionFromDefinition() {
final Element element = mock(Element.class);
final View elementContent = mock(View.class);
final HasExpression newHasExpression = mock(HasExpression.class);
final HasExpression hasExpression = mock(HasExpression.class);
final Expression expression = mock(Expression.class);
when(element.getContent()).thenReturn(elementContent);
when(elementContent.getDefinition()).thenReturn(newHasExpression);
when(hasExpression.getExpression()).thenReturn(expression);
observerBuilderControl.updateElementFromDefinition(element, hasExpression);
verify(newHasExpression).setExpression(expression);
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class RelationEditorDefinitionTest method testEditor.
@Test
public void testEditor() {
when(hasExpression.getExpression()).thenReturn(definition.getModelClass().get());
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, hasName, false, 0);
assertThat(oEditor).isPresent();
final GridWidget editor = oEditor.get();
assertThat(editor).isInstanceOf(RelationGrid.class);
}
Aggregations