use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemViewTest method testSetupReadOnlyCSSClassWhenDataTypeHasSubDataTypes.
@Test
public void testSetupReadOnlyCSSClassWhenDataTypeHasSubDataTypes() {
final DataType dataType = mock(DataType.class);
dragAndDropElement.classList = mock(DOMTokenList.class);
when(dataType.isReadOnly()).thenReturn(true);
view.setupReadOnlyCSSClass(dataType);
verify(dragAndDropElement.classList).add("read-only");
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListItemViewTest method testEnableFocusMode.
@Test
public void testEnableFocusMode() {
final DataType parentDataType = mock(DataType.class);
final String parentDataTypeUUID = "parentDataTypeUUID";
final Element parentElement = mock(Element.class);
final Element child1 = makeChildElement("child1UUID");
final Element child2 = makeChildElement("child2UUID");
final NodeList<Element> children = spy(new NodeList<>());
when(parentDataType.getUUID()).thenReturn(parentDataTypeUUID);
when(parentElement.getAttribute("data-row-uuid")).thenReturn(parentDataTypeUUID);
doReturn(parentDataType).when(view).getDataType();
doReturn(child1).when(children).getAt(0);
doReturn(child2).when(children).getAt(1);
doReturn(nameInput).when(view).getNameInput();
mockDOMElementByUUID(parentDataTypeUUID, parentElement);
mockDOMElementsByParentUUID(parentDataTypeUUID, children);
children.length = 2;
parentElement.classList = mock(DOMTokenList.class);
view.enableFocusMode();
verify(parentElement.classList).add(FOCUSED_CSS_CLASS);
verify(child1.classList).add(FOCUSED_CSS_CLASS);
verify(child2.classList).add(FOCUSED_CSS_CLASS);
verify(nameInput).select();
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListViewTest method testRemoveItem.
@Test
public void testRemoveItem() {
final String uuid = "uuid";
final DataType dataType = mock(DataType.class);
final Node parentNode = mock(Node.class);
final Element dataTypeElement = makeElement(uuid);
when(dataType.getUUID()).thenReturn(uuid);
doReturn(dataTypeElement).when(view).getDataTypeRow(dataType);
doNothing().when(view).cleanSubTypes(Mockito.<String>any());
dataTypeElement.parentNode = parentNode;
view.removeItem(dataType);
verify(presenter).removeItem(uuid);
verify(view).cleanSubTypes(uuid);
verify(parentNode).removeChild(dataTypeElement);
verify(view).showOrHideNoCustomItemsMessage();
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeSelectTest method testGetCustomDataTypes.
@Test
public void testGetCustomDataTypes() {
final DataType dataType1 = mock(DataType.class);
final DataType dataType2 = mock(DataType.class);
final DataType dataType3 = mock(DataType.class);
final List<DataType> customDataTypes = asList(dataType1, dataType2, dataType3);
when(dataType1.getName()).thenReturn("tUUID");
when(dataType2.getName()).thenReturn("tPerson");
when(dataType3.getName()).thenReturn("tCity");
when(dataTypeUtils.customDataTypes()).thenReturn(customDataTypes);
doReturn(dataType2).when(dataTypeSelect).getDataType();
final List<DataType> actualDataTypes = dataTypeSelect.getCustomDataTypes();
final List<DataType> expectedDataTypes = asList(dataType1, dataType3);
assertEquals(expectedDataTypes, actualDataTypes);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeNameIsInvalidErrorMessageTest method testGetStrongMessage.
@Test
public void testGetStrongMessage() {
final DataType dataType = mock(DataType.class);
final String expectedErrorMessage = "*Expected strong message.*";
final DataTypeNameIsInvalidErrorMessage errorMessage = new DataTypeNameIsInvalidErrorMessage(translationService);
when(translationService.format(DataTypeNameIsInvalidErrorMessage_StrongMessage)).thenReturn(expectedErrorMessage);
final String actualErrorMessage = errorMessage.getStrongMessage(dataType);
assertEquals(expectedErrorMessage, actualErrorMessage);
}
Aggregations