Search in sources :

Example 71 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class DataTypeListItemViewTest method testSetupReadOnlyCSSClassWhenIsReadOnlyDiagram.

@Test
public void testSetupReadOnlyCSSClassWhenIsReadOnlyDiagram() {
    final DataType dataType = mock(DataType.class);
    dragAndDropElement.classList = mock(DOMTokenList.class);
    when(dataType.isReadOnly()).thenReturn(false);
    when(readOnlyProvider.isReadOnlyDiagram()).thenReturn(true);
    view.setupReadOnlyCSSClass(dataType);
    verify(dragAndDropElement.classList).add("read-only");
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 72 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class DataTypeListItemViewTest method testIsOnFocusModeWhenItReturnsTrue.

@Test
public void testIsOnFocusModeWhenItReturnsTrue() {
    final DataType dataType = mock(DataType.class);
    final Element dataTypeRow = mock(Element.class);
    dataTypeRow.classList = mock(DOMTokenList.class);
    doReturn(dataType).when(view).getDataType();
    doReturn(dataTypeRow).when(view).getRowElement(dataType);
    when(dataTypeRow.classList.contains(FOCUSED_CSS_CLASS)).thenReturn(true);
    assertTrue(view.isOnFocusMode());
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) Element(elemental2.dom.Element) HTMLInputElement(elemental2.dom.HTMLInputElement) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 73 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class WarningMessageTest method testGetFlashMessage.

@Test
public void testGetFlashMessage() {
    final String uuid = "uuid";
    final FlashMessage.Type expectedType = WARNING;
    final String expectedStrongMessage = "expectedStrongMessage";
    final String expectedRegularMessage = "expectedRegularMessage";
    final String expectedErrorElementSelector = "[data-row-uuid=\"uuid\"] .bootstrap-select";
    final Command expectedOnSuccessCallback = mock(Command.class);
    final Command expectedOnErrorCallback = mock(Command.class);
    final DataType dataType = mock(DataType.class);
    final WarningMessage errorMessage = new WarningMessage(translationService) {

        @Override
        String getStrongMessage(final DataType dataType) {
            return expectedStrongMessage;
        }

        @Override
        String getRegularMessage() {
            return expectedRegularMessage;
        }
    };
    when(dataType.getUUID()).thenReturn(uuid);
    final FlashMessage flashMessage = errorMessage.getFlashMessage(dataType, expectedOnSuccessCallback, expectedOnErrorCallback);
    final FlashMessage.Type actualType = flashMessage.getType();
    final String actualStrongMessage = flashMessage.getStrongMessage();
    final String actualRegularMessage = flashMessage.getRegularMessage();
    final String actualErrorElementSelector = flashMessage.getElementSelector();
    final Command actualOnSuccessCallback = flashMessage.getOnSuccess();
    final Command actualOnErrorCallback = flashMessage.getOnError();
    assertEquals(expectedType, actualType);
    assertEquals(expectedStrongMessage, actualStrongMessage);
    assertEquals(expectedRegularMessage, actualRegularMessage);
    assertEquals(expectedErrorElementSelector, actualErrorElementSelector);
    assertEquals(expectedOnSuccessCallback, actualOnSuccessCallback);
    assertEquals(expectedOnErrorCallback, actualOnErrorCallback);
}
Also used : Command(org.uberfire.mvp.Command) FlashMessage(org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 74 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class DataTypeUpdateHandlerTest method testRefreshSubDataType.

@Test
public void testRefreshSubDataType() {
    final DataType dataType = mock(DataType.class);
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    final String newType = "newType";
    final String type = "type";
    final String uuid = "uuid";
    when(dataType.getType()).thenReturn(type);
    when(dataType.getUUID()).thenReturn(uuid);
    when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition);
    when(dataTypeManager.from(dataType)).thenReturn(dataTypeManager);
    when(dataTypeManager.withType(newType)).thenReturn(dataTypeManager);
    handler.refreshSubDataType(dataType, newType);
    final InOrder inOrder = Mockito.inOrder(dataTypeManager, dataTypeManager, recordEngine, handler);
    inOrder.verify(dataTypeManager).from(dataType);
    inOrder.verify(dataTypeManager).withType(newType);
    inOrder.verify(recordEngine).doUpdate(dataType, itemDefinition);
}
Also used : InOrder(org.mockito.InOrder) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 75 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class DataTypeUpdateHandlerTest method testUpdateWhenDataTypeIsNotStructure.

@Test
public void testUpdateWhenDataTypeIsNotStructure() {
    final DataType dataType = mock(DataType.class);
    doReturn(false).when(handler).isStructure(dataType);
    when(dataTypeManager.from(dataType)).thenReturn(dataTypeManager);
    handler.update(dataType);
    verify(dataTypeManager).withSubDataTypes(emptyList());
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Aggregations

DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)274 Test (org.junit.Test)245 HTMLElement (elemental2.dom.HTMLElement)44 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)39 Element (elemental2.dom.Element)30 ArrayList (java.util.ArrayList)26 DOMTokenList (elemental2.dom.DOMTokenList)24 DataTypeListItem (org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem)14 HTMLDivElement (elemental2.dom.HTMLDivElement)13 HTMLButtonElement (elemental2.dom.HTMLButtonElement)12 Command (org.uberfire.mvp.Command)12 FlashMessage (org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage)9 DataTypeManager (org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager)9 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)8 DNDListComponent (org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)7 HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)6 HTMLInputElement (elemental2.dom.HTMLInputElement)6 DataObject (org.kie.workbench.common.dmn.api.editors.types.DataObject)6