Search in sources :

Example 1 with MockInstanceImpl

use of org.uberfire.mocks.MockInstanceImpl 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)

Example 2 with MockInstanceImpl

use of org.uberfire.mocks.MockInstanceImpl in project kie-wb-common by kiegroup.

the class AbstractCanvasShortcutsControlImplTest method setUp.

@Before
public void setUp() throws Exception {
    shortcuts = new MockInstanceImpl(keyboardShortcutAction);
    canvasShortcutsControl = new AbstractCanvasShortcutsControlImpl(shortcuts) {

        {
            this.canvasHandler = canvasHandlerMock;
        }
    };
}
Also used : MockInstanceImpl(org.uberfire.mocks.MockInstanceImpl) Before(org.junit.Before)

Example 3 with MockInstanceImpl

use of org.uberfire.mocks.MockInstanceImpl in project kie-wb-common by kiegroup.

the class ProjectValidationServiceImplTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() {
    domainViolationList = Arrays.asList(domainViolation, domainViolation2, domainViolation3, domainViolation4, domainViolationNull, domainViolationNullStr);
    domainValidator = new DomainValidator() {

        @Override
        public String getDefinitionSetId() {
            return DEF_SET_ID;
        }

        @Override
        public void validate(Diagram entity, Consumer<Collection<DomainViolation>> resultConsumer) {
            resultConsumer.accept(domainViolationList);
        }
    };
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getDefinitionSetId()).thenReturn(DEF_SET_ID);
    when(diagram.getGraph()).thenReturn(graph);
    when(graph.getUUID()).thenReturn(GRAPH_UUID);
    mockViolations(domainViolationList);
    validationService = new ProjectValidationServiceImpl(new MockInstanceImpl(domainValidator));
}
Also used : MockInstanceImpl(org.uberfire.mocks.MockInstanceImpl) Collection(java.util.Collection) DomainValidator(org.kie.workbench.common.stunner.core.validation.DomainValidator) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)3 MockInstanceImpl (org.uberfire.mocks.MockInstanceImpl)3 Column (com.google.gwt.user.cellview.client.Column)1 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)1 Collection (java.util.Collection)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 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 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)1 DomainValidator (org.kie.workbench.common.stunner.core.validation.DomainValidator)1