use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class ReferencedDataTypeWarningMessageTest method testGetErrorElementSelector.
@Test
public void testGetErrorElementSelector() {
final DataType dataType = mock(DataType.class);
when(dataType.getUUID()).thenReturn("1111-1111-1111-1111");
final String expectedSelector = "[data-row-uuid=\"1111-1111-1111-1111\"] select";
final String actualSelector = new ReferencedDataTypeWarningMessage(translationService).getErrorElementSelector(dataType);
assertEquals(expectedSelector, actualSelector);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeConstraintTest method testInit.
@Test
public void testInit() {
final DataTypeListItem expectedListItem = mock(DataTypeListItem.class);
final DataType datatype = mock(DataType.class);
final String expectedConstraint = "constraint";
final ConstraintType expectedType = mock(ConstraintType.class);
when(expectedListItem.getDataType()).thenReturn(datatype);
when(datatype.getConstraint()).thenReturn(expectedConstraint);
when(datatype.getConstraintType()).thenReturn(expectedType);
dataTypeConstraint.init(expectedListItem);
final DataTypeListItem actualListItem = dataTypeConstraint.getListItem();
final String actualConstraint = dataTypeConstraint.getValue();
final ConstraintType actualType = dataTypeConstraint.getConstraintType();
assertEquals(expectedType, actualType);
assertEquals(expectedListItem, actualListItem);
assertEquals(expectedConstraint, actualConstraint);
verify(dataTypeConstraint).refreshView();
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemTest method testDiscardDataTypeProperties.
@Test
public void testDiscardDataTypeProperties() {
final DataType dataType = spy(makeDataType());
final String expectedName = "name";
final String expectedType = "type";
final String expectedConstraint = "constraint";
final String expectedConstraintType = "enumeration";
final boolean expectedIsList = true;
doReturn(dataType).when(listItem).getDataType();
doReturn(expectedName).when(listItem).getOldName();
doReturn(expectedType).when(listItem).getOldType();
doReturn(expectedConstraint).when(listItem).getOldConstraint();
doReturn(expectedIsList).when(listItem).getOldIsList();
doReturn(expectedConstraintType).when(listItem).getOldConstraintType();
listItem.discardDataTypeProperties();
assertEquals(expectedName, dataType.getName());
assertEquals(expectedType, dataType.getType());
assertEquals(expectedConstraint, dataType.getConstraint());
assertEquals(expectedIsList, dataType.isList());
assertEquals(expectedConstraintType, dataType.getConstraintType().value());
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemTest method testIsIndirectTypeOfWhenIsStructureRecursive.
@Test
public void testIsIndirectTypeOfWhenIsStructureRecursive() {
// some(tIndirectType) -> tIndirectType(tIndirectStructure) -> tIndirectStructure(Structure)
final String indirectType = "tIndirectType";
final String tIndirectStructure = "tIndirectStructure";
final DataType dataType1 = mock(DataType.class);
final DataType dataType2 = mock(DataType.class);
final List<DataType> customDataTypes = asList(dataType1, dataType2);
when(dataType1.getName()).thenReturn(indirectType);
when(dataType1.getType()).thenReturn(tIndirectStructure);
when(dataType2.getName()).thenReturn(tIndirectStructure);
when(dataType2.getType()).thenReturn(structure);
when(dataTypeSelectComponent.getValue()).thenReturn(indirectType);
when(dataTypeSelectComponent.getCustomDataTypes()).thenReturn(customDataTypes);
final boolean actual = listItem.isIndirectCanNotHaveConstraintType();
assertTrue(actual);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemTest method testSetupView.
@Test
public void testSetupView() {
final DataType dataType = mock(DataType.class);
when(listItem.getDataType()).thenReturn(dataType);
doNothing().when(listItem).setupIndentationLevel();
doNothing().when(listItem).hideTooltips();
listItem.setupView();
verify(view).setupSelectComponent(dataTypeSelectComponent);
verify(view).setupConstraintComponent(dataTypeConstraintComponent);
verify(view).setupListComponent(dataTypeListComponent);
verify(view).setDataType(dataType);
verify(listItem).setupIndentationLevel();
verify(listItem).hideTooltips();
}
Aggregations