Search in sources :

Example 6 with BaseIncludedModelActiveRecord

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

the class BaseCardComponentTest method testOnTitleChangedWhenIncludedModelIsNotValid.

@Test
public void testOnTitleChangedWhenIncludedModelIsNotValid() {
    final DMNCardsGridComponent grid = mock(DMNCardsGridComponent.class);
    final BaseIncludedModelActiveRecord includedModel = prepareIncludedModelMock();
    final String newName = "newName";
    final String oldName = "oldName";
    when(includedModel.getName()).thenReturn(oldName);
    doReturn(false).when(includedModel).isValid();
    doReturn(includedModel).when(card).getIncludedModel();
    doReturn(grid).when(card).getGrid();
    final boolean titleChanged = card.onTitleChanged().apply(newName);
    assertEquals(oldName, includedModel.getName());
    assertFalse(titleChanged);
    verify(includedModel, never()).update();
    verify(grid, never()).refresh();
    verify(card, never()).refreshDecisionComponents();
}
Also used : BaseIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord) Test(org.junit.Test)

Example 7 with BaseIncludedModelActiveRecord

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

the class BaseCardComponentTest method testGetUUID.

@Test
public void testGetUUID() {
    final BaseIncludedModelActiveRecord includedModel = prepareIncludedModelMock();
    final String expectedUUID = "123";
    when(includedModel.getUUID()).thenReturn(expectedUUID);
    doReturn(includedModel).when(card).getIncludedModel();
    final String actualUUID = card.getUUID();
    assertEquals(expectedUUID, actualUUID);
}
Also used : BaseIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord) Test(org.junit.Test)

Example 8 with BaseIncludedModelActiveRecord

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

the class BaseCardComponentTest method testSetup.

@Test
public void testSetup() {
    final DMNCardsGridComponent expectedGrid = mock(DMNCardsGridComponent.class);
    final R expectedIncludedModel = mock(getActiveRecordClass());
    when(expectedIncludedModel.getNamespace()).thenReturn("://namespace");
    card.setup(expectedGrid, expectedIncludedModel);
    final DMNCardsGridComponent actualGrid = card.getGrid();
    final BaseIncludedModelActiveRecord actualIncludedModel = card.getIncludedModel();
    verify(card).refreshView();
    assertEquals(expectedGrid, actualGrid);
    assertEquals(expectedIncludedModel, actualIncludedModel);
}
Also used : BaseIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord) Test(org.junit.Test)

Example 9 with BaseIncludedModelActiveRecord

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

the class ImportRecordEngineTest method testCreate.

@Test
public void testCreate() {
    final BaseIncludedModelActiveRecord record = mock(BaseIncludedModelActiveRecord.class);
    final Import import1 = mock(Import.class);
    final Import import2 = mock(Import.class);
    final Import import3 = mock(Import.class);
    final List<Import> expectedImports = asList(import1, import2, import3);
    final List<Import> actualImports = new ArrayList<>(asList(import1, import2));
    when(importFactory.makeImport(record)).thenReturn(import3);
    when(stateProvider.getImports()).thenReturn(actualImports);
    final List<BaseIncludedModelActiveRecord> actualResult = recordEngine.create(record);
    final List<BaseIncludedModelActiveRecord> expectedResult = singletonList(record);
    verify(definitionsHandler).create(record);
    assertEquals(expectedImports, actualImports);
    assertEquals(expectedResult, actualResult);
}
Also used : Import(org.kie.workbench.common.dmn.api.definition.model.Import) ArrayList(java.util.ArrayList) BaseIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord) Test(org.junit.Test)

Example 10 with BaseIncludedModelActiveRecord

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

the class ImportRecordEngineTest method testUpdateWhenIncludedModelIsValid.

@Test
public void testUpdateWhenIncludedModelIsValid() {
    final BaseIncludedModelActiveRecord record = mock(BaseIncludedModelActiveRecord.class);
    final ArgumentCaptor<Name> nameCaptor = ArgumentCaptor.forClass(Name.class);
    final Import anImport = mock(Import.class);
    final String name = "name";
    final String oldName = "oldName";
    when(record.getName()).thenReturn(name);
    when(record.isValid()).thenReturn(true);
    when(includedModelsIndex.getImport(record)).thenReturn(anImport);
    when(anImport.getName()).thenReturn(new Name(oldName));
    final List<BaseIncludedModelActiveRecord> actualResult = recordEngine.update(record);
    final List<BaseIncludedModelActiveRecord> expectedResult = singletonList(record);
    verify(anImport).setName(nameCaptor.capture());
    verify(itemDefinitionHandler).update(oldName, name);
    verify(dmnIncludedModelHandler).update(oldName, name);
    verify(pmmlIncludedModelHandler).update(oldName, name);
    final Name actualName = nameCaptor.getValue();
    final Name expectedName = new Name(name);
    assertEquals(expectedName, actualName);
    assertEquals(expectedResult, actualResult);
}
Also used : Import(org.kie.workbench.common.dmn.api.definition.model.Import) BaseIncludedModelActiveRecord(org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Aggregations

BaseIncludedModelActiveRecord (org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord)32 Test (org.junit.Test)27 Import (org.kie.workbench.common.dmn.api.definition.model.Import)11 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)7 ArrayList (java.util.ArrayList)6 FlashMessage (org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage)6 DMNIncludedModelActiveRecord (org.kie.workbench.common.dmn.client.editors.included.DMNIncludedModelActiveRecord)6 PMMLIncludedModelActiveRecord (org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord)5 KieAssetsDropdownItem (org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem)4 Maps (org.kie.soup.commons.util.Maps)3 RefreshDecisionComponents (org.kie.workbench.common.dmn.client.docks.navigator.events.RefreshDecisionComponents)3 ImportDMN (org.kie.workbench.common.dmn.api.definition.model.ImportDMN)2 ImportPMML (org.kie.workbench.common.dmn.api.definition.model.ImportPMML)2 LocationURI (org.kie.workbench.common.dmn.api.property.dmn.LocationURI)2 Type (org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage.Type)2 DefaultIncludedModelActiveRecord (org.kie.workbench.common.dmn.client.editors.included.DefaultIncludedModelActiveRecord)2 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)1 HTMLElement (elemental2.dom.HTMLElement)1 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1