Search in sources :

Example 1 with FieldMetadata

use of org.kie.workbench.common.screens.datamodeller.model.editor.FieldMetadata in project kie-wb-common by kiegroup.

the class DataObjectBrowserViewImplTest method addPropertyTypeBrowseColumn.

@Test
public void addPropertyTypeBrowseColumn() {
    FieldMetadataProvider fieldMetadataProvider = objectProperty -> {
        if ("testField".equals(objectProperty.getName())) {
            ImageWrapper imageWrapper = new ImageWrapper("testUri", "testDescription");
            FieldMetadata fieldMetadata = new FieldMetadata(imageWrapper);
            return Optional.of(fieldMetadata);
        }
        return Optional.empty();
    };
    Instance<FieldMetadataProvider> fieldMetadataProviderInstance = new MockInstanceImpl<>(fieldMetadataProvider);
    view = new DataObjectBrowserViewImpl(validationPopup, fieldMetadataProviderInstance);
    Column<ObjectProperty, List<ImageWrapper>> column = view.createPropertyTypeBrowseColumn();
    ObjectProperty matchingObjectProperty = new ObjectPropertyImpl("testField", "className", false);
    List<ImageWrapper> imageWrapperList = column.getValue(matchingObjectProperty);
    assertEquals(1, imageWrapperList.size());
    ObjectProperty nonMatchingObjectProperty = new ObjectPropertyImpl("nonMatchingTestField", "className", false);
    imageWrapperList = column.getValue(nonMatchingObjectProperty);
    assertEquals(0, imageWrapperList.size());
}
Also used : GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) ObjectProperty(org.kie.workbench.common.services.datamodeller.core.ObjectProperty) FieldMetadata(org.kie.workbench.common.screens.datamodeller.model.editor.FieldMetadata) Mock(org.mockito.Mock) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) ObjectPropertyImpl(org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl) FieldMetadataProvider(org.kie.workbench.common.screens.datamodeller.model.editor.FieldMetadataProvider) ValidationPopup(org.kie.workbench.common.widgets.client.popups.validation.ValidationPopup) ImageWrapper(org.kie.workbench.common.screens.datamodeller.model.editor.ImageWrapper) Mockito(org.mockito.Mockito) List(java.util.List) Column(com.google.gwt.user.cellview.client.Column) Optional(java.util.Optional) MockInstanceImpl(org.uberfire.mocks.MockInstanceImpl) Assert(org.junit.Assert) Collections(java.util.Collections) Instance(javax.enterprise.inject.Instance) Command(org.uberfire.mvp.Command) Before(org.junit.Before) ObjectProperty(org.kie.workbench.common.services.datamodeller.core.ObjectProperty) ObjectPropertyImpl(org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl) FieldMetadataProvider(org.kie.workbench.common.screens.datamodeller.model.editor.FieldMetadataProvider) FieldMetadata(org.kie.workbench.common.screens.datamodeller.model.editor.FieldMetadata) ImageWrapper(org.kie.workbench.common.screens.datamodeller.model.editor.ImageWrapper) MockInstanceImpl(org.uberfire.mocks.MockInstanceImpl) List(java.util.List) Test(org.junit.Test)

Aggregations

Column (com.google.gwt.user.cellview.client.Column)1 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 Instance (javax.enterprise.inject.Instance)1 ValidationMessage (org.guvnor.common.services.shared.validation.model.ValidationMessage)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1 FieldMetadata (org.kie.workbench.common.screens.datamodeller.model.editor.FieldMetadata)1 FieldMetadataProvider (org.kie.workbench.common.screens.datamodeller.model.editor.FieldMetadataProvider)1 ImageWrapper (org.kie.workbench.common.screens.datamodeller.model.editor.ImageWrapper)1 ObjectProperty (org.kie.workbench.common.services.datamodeller.core.ObjectProperty)1 ObjectPropertyImpl (org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl)1 ValidationPopup (org.kie.workbench.common.widgets.client.popups.validation.ValidationPopup)1 Mock (org.mockito.Mock)1 Mockito (org.mockito.Mockito)1 MockInstanceImpl (org.uberfire.mocks.MockInstanceImpl)1