use of org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord in project kie-wb-common by kiegroup.
the class ImportRecordEngineTest method testIsValidWhenNameIsNotUnique.
@Test
public void testIsValidWhenNameIsNotUnique() {
final BaseIncludedModelActiveRecord record = mock(BaseIncludedModelActiveRecord.class);
final Import import1 = mock(Import.class);
final Import import2 = mock(Import.class);
final Name name1 = mock(Name.class);
final Name name2 = mock(Name.class);
final FlashMessage flashMessage = mock(FlashMessage.class);
final List<Import> imports = new ArrayList<>(asList(import1, import2));
when(name1.getValue()).thenReturn("file1");
when(name2.getValue()).thenReturn("file2");
when(record.getName()).thenReturn("file1");
when(import1.getName()).thenReturn(name1);
when(import2.getName()).thenReturn(name2);
when(includedModelsIndex.getImport(record)).thenReturn(import2);
when(stateProvider.getImports()).thenReturn(imports);
when(messageFactory.getNameIsNotUniqueFlashMessage(record)).thenReturn(flashMessage);
final boolean valid = recordEngine.isValid(record);
assertFalse(valid);
verify(flashMessageEvent).fire(flashMessage);
}
use of org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord in project kie-wb-common by kiegroup.
the class IncludedModelModalTest method doTestCreateIncludedModel.
@SuppressWarnings("unchecked")
private void doTestCreateIncludedModel(final String name, final String expectedName) {
final String value = "://namespace";
final String path = "/src/path/file";
final String anPackage = "path.file.com";
final Integer expectedDrgElementsCount = 2;
final Integer expectedDataTypesCount = 3;
final Map<String, String> metaData = new Maps.Builder<String, String>().put(PATH_METADATA, path).put(IMPORT_TYPE_METADATA, DMNImportTypes.DMN.getDefaultNamespace()).put(DRG_ELEMENT_COUNT_METADATA, expectedDrgElementsCount.toString()).put(ITEM_DEFINITION_COUNT_METADATA, expectedDataTypesCount.toString()).build();
when(view.getModelNameInput()).thenReturn(name);
final BaseIncludedModelActiveRecord includedModel = modal.createIncludedModel(new KieAssetsDropdownItem(name, anPackage, value, metaData));
assertTrue(includedModel instanceof DMNIncludedModelActiveRecord);
final DMNIncludedModelActiveRecord dmnIncludedModel = (DMNIncludedModelActiveRecord) includedModel;
assertEquals(expectedName, dmnIncludedModel.getName());
assertEquals(value, dmnIncludedModel.getNamespace());
assertEquals(path, dmnIncludedModel.getPath());
assertEquals(expectedDrgElementsCount, dmnIncludedModel.getDrgElementsCount());
assertEquals(expectedDataTypesCount, dmnIncludedModel.getDataTypesCount());
}
use of org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord in project kie-wb-common by kiegroup.
the class BaseCardComponentTest method testGetSubTitleWhenPathIsNotEmpty.
@Test
public void testGetSubTitleWhenPathIsNotEmpty() {
final BaseIncludedModelActiveRecord includedModel = prepareIncludedModelMock();
final String expected = "/src/path/kie/dmn";
doReturn(includedModel).when(card).getIncludedModel();
when(includedModel.getPath()).thenReturn(expected);
final String actual = card.getSubTitle();
assertEquals(expected, actual);
}
use of org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord in project kie-wb-common by kiegroup.
the class BaseCardComponentTest method doTestOnTitleChangedWhenIncludedModelIsValid.
private void doTestOnTitleChangedWhenIncludedModelIsValid(final String newName, final String expectedNewName) {
final DMNCardsGridComponent grid = mock(DMNCardsGridComponent.class);
final BaseIncludedModelActiveRecord includedModel = prepareIncludedModelMock();
when(includedModel.getName()).thenReturn(expectedNewName);
doReturn(true).when(includedModel).isValid();
doReturn(emptyList()).when(includedModel).update();
doReturn(includedModel).when(card).getIncludedModel();
doReturn(grid).when(card).getGrid();
final boolean titleChanged = card.onTitleChanged().apply(newName);
assertEquals(expectedNewName, includedModel.getName());
assertTrue(titleChanged);
verify(includedModel).update();
verify(grid).refresh();
verify(card).refreshDecisionComponents();
}
use of org.kie.workbench.common.dmn.client.editors.included.BaseIncludedModelActiveRecord in project kie-wb-common by kiegroup.
the class BaseCardComponentTest method testGetSubTitleWhenPathIsEmpty.
@Test
public void testGetSubTitleWhenPathIsEmpty() {
final BaseIncludedModelActiveRecord includedModel = prepareIncludedModelMock();
final String expected = "://namespace";
doReturn(includedModel).when(card).getIncludedModel();
when(includedModel.getPath()).thenReturn("");
when(includedModel.getNamespace()).thenReturn(expected);
final String actual = card.getSubTitle();
assertEquals(expected, actual);
}
Aggregations