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();
}
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);
}
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);
}
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);
}
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);
}
Aggregations