Search in sources :

Example 1 with IQueryService

use of org.eclipse.sirius.components.collaborative.api.IQueryService in project sirius-components by eclipse-sirius.

the class QueryBasedBooleanEventHandlerTests method testQueryBasedBooleanFailed.

@Test
public void testQueryBasedBooleanFailed() {
    IQueryService queryService = new IQueryService.NoOp() {

        @Override
        public IPayload execute(IEditingContext editingContext, QueryBasedBooleanInput input) {
            // $NON-NLS-1$
            return new ErrorPayload(UUID.randomUUID(), "An error occured");
        }
    };
    Many<ChangeDescription> changeDescriptionSink = Sinks.many().unicast().onBackpressureBuffer();
    One<IPayload> payloadSink = Sinks.one();
    this.handle(payloadSink, changeDescriptionSink, queryService);
    ChangeDescription changeDescription = changeDescriptionSink.asFlux().blockFirst();
    assertThat(changeDescription.getKind()).isEqualTo(ChangeKind.NOTHING);
    IPayload payload = payloadSink.asMono().block();
    assertThat(payload).isInstanceOf(ErrorPayload.class);
}
Also used : ErrorPayload(org.eclipse.sirius.components.core.api.ErrorPayload) IQueryService(org.eclipse.sirius.components.collaborative.api.IQueryService) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) QueryBasedBooleanInput(org.eclipse.sirius.components.collaborative.dto.QueryBasedBooleanInput) IPayload(org.eclipse.sirius.components.core.api.IPayload) Test(org.junit.jupiter.api.Test)

Example 2 with IQueryService

use of org.eclipse.sirius.components.collaborative.api.IQueryService in project sirius-components by eclipse-sirius.

the class QueryBasedIntEventHandlerTests method testQueryBasedInt.

@Test
public void testQueryBasedInt() {
    IQueryService queryService = new IQueryService.NoOp() {

        @Override
        public IPayload execute(IEditingContext editingContext, QueryBasedIntInput input) {
            return new QueryBasedIntSuccessPayload(UUID.randomUUID(), EXPECTED_RESULT_10);
        }
    };
    Many<ChangeDescription> changeDescriptionSink = Sinks.many().unicast().onBackpressureBuffer();
    One<IPayload> payloadSink = Sinks.one();
    this.handle(payloadSink, changeDescriptionSink, queryService);
    ChangeDescription changeDescription = changeDescriptionSink.asFlux().blockFirst();
    assertThat(changeDescription.getKind()).isEqualTo(ChangeKind.NOTHING);
    IPayload payload = payloadSink.asMono().block();
    assertThat(payload).isInstanceOf(QueryBasedIntSuccessPayload.class);
    assertThat(((QueryBasedIntSuccessPayload) payload).getResult()).isEqualTo(EXPECTED_RESULT_10);
}
Also used : QueryBasedIntInput(org.eclipse.sirius.components.collaborative.dto.QueryBasedIntInput) QueryBasedIntSuccessPayload(org.eclipse.sirius.components.collaborative.dto.QueryBasedIntSuccessPayload) IQueryService(org.eclipse.sirius.components.collaborative.api.IQueryService) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) IPayload(org.eclipse.sirius.components.core.api.IPayload) Test(org.junit.jupiter.api.Test)

Example 3 with IQueryService

use of org.eclipse.sirius.components.collaborative.api.IQueryService in project sirius-components by eclipse-sirius.

the class QueryBasedObjectEventHandlerTests method testQueryBasedObjectFailed.

@Test
public void testQueryBasedObjectFailed() {
    IQueryService queryService = new IQueryService.NoOp() {

        @Override
        public IPayload execute(IEditingContext editingContext, QueryBasedObjectInput input) {
            // $NON-NLS-1$
            return new ErrorPayload(UUID.randomUUID(), "An error occured");
        }
    };
    Many<ChangeDescription> changeDescriptionSink = Sinks.many().unicast().onBackpressureBuffer();
    One<IPayload> payloadSink = Sinks.one();
    this.handle(payloadSink, changeDescriptionSink, queryService);
    ChangeDescription changeDescription = changeDescriptionSink.asFlux().blockFirst();
    assertThat(changeDescription.getKind()).isEqualTo(ChangeKind.NOTHING);
    IPayload payload = payloadSink.asMono().block();
    assertThat(payload).isInstanceOf(ErrorPayload.class);
}
Also used : ErrorPayload(org.eclipse.sirius.components.core.api.ErrorPayload) IQueryService(org.eclipse.sirius.components.collaborative.api.IQueryService) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) QueryBasedObjectInput(org.eclipse.sirius.components.collaborative.dto.QueryBasedObjectInput) IPayload(org.eclipse.sirius.components.core.api.IPayload) Test(org.junit.jupiter.api.Test)

Example 4 with IQueryService

use of org.eclipse.sirius.components.collaborative.api.IQueryService in project sirius-components by eclipse-sirius.

the class QueryBasedObjectsEventHandlerTests method testQueryBasedObjects.

@Test
public void testQueryBasedObjects() {
    IQueryService queryService = new IQueryService.NoOp() {

        @Override
        public IPayload execute(IEditingContext editingContext, QueryBasedObjectsInput input) {
            return new QueryBasedObjectsSuccessPayload(UUID.randomUUID(), EXPECTED_RESULT);
        }
    };
    Many<ChangeDescription> changeDescriptionSink = Sinks.many().unicast().onBackpressureBuffer();
    One<IPayload> payloadSink = Sinks.one();
    this.handle(payloadSink, changeDescriptionSink, queryService);
    ChangeDescription changeDescription = changeDescriptionSink.asFlux().blockFirst();
    assertThat(changeDescription.getKind()).isEqualTo(ChangeKind.NOTHING);
    IPayload payload = payloadSink.asMono().block();
    assertThat(payload).isInstanceOf(QueryBasedObjectsSuccessPayload.class);
    assertThat(((QueryBasedObjectsSuccessPayload) payload).getResult()).isEqualTo(EXPECTED_RESULT);
}
Also used : IQueryService(org.eclipse.sirius.components.collaborative.api.IQueryService) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) QueryBasedObjectsSuccessPayload(org.eclipse.sirius.components.collaborative.dto.QueryBasedObjectsSuccessPayload) QueryBasedObjectsInput(org.eclipse.sirius.components.collaborative.dto.QueryBasedObjectsInput) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) IPayload(org.eclipse.sirius.components.core.api.IPayload) Test(org.junit.jupiter.api.Test)

Example 5 with IQueryService

use of org.eclipse.sirius.components.collaborative.api.IQueryService in project sirius-components by eclipse-sirius.

the class QueryBasedObjectsEventHandlerTests method testQueryBasedObjectsFailed.

@Test
public void testQueryBasedObjectsFailed() {
    IQueryService queryService = new IQueryService.NoOp() {

        @Override
        public IPayload execute(IEditingContext editingContext, QueryBasedObjectsInput input) {
            // $NON-NLS-1$
            return new ErrorPayload(UUID.randomUUID(), "An error occured");
        }
    };
    Many<ChangeDescription> changeDescriptionSink = Sinks.many().unicast().onBackpressureBuffer();
    One<IPayload> payloadSink = Sinks.one();
    this.handle(payloadSink, changeDescriptionSink, queryService);
    ChangeDescription changeDescription = changeDescriptionSink.asFlux().blockFirst();
    assertThat(changeDescription.getKind()).isEqualTo(ChangeKind.NOTHING);
    IPayload payload = payloadSink.asMono().block();
    assertThat(payload).isInstanceOf(ErrorPayload.class);
}
Also used : ErrorPayload(org.eclipse.sirius.components.core.api.ErrorPayload) IQueryService(org.eclipse.sirius.components.collaborative.api.IQueryService) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) QueryBasedObjectsInput(org.eclipse.sirius.components.collaborative.dto.QueryBasedObjectsInput) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) IPayload(org.eclipse.sirius.components.core.api.IPayload) Test(org.junit.jupiter.api.Test)

Aggregations

IQueryService (org.eclipse.sirius.components.collaborative.api.IQueryService)13 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)13 IPayload (org.eclipse.sirius.components.core.api.IPayload)13 Test (org.junit.jupiter.api.Test)13 ChangeDescription (org.eclipse.sirius.components.collaborative.api.ChangeDescription)10 ErrorPayload (org.eclipse.sirius.components.core.api.ErrorPayload)6 QueryBasedIntInput (org.eclipse.sirius.components.collaborative.dto.QueryBasedIntInput)4 EPackage (org.eclipse.emf.ecore.EPackage)3 QueryBasedIntSuccessPayload (org.eclipse.sirius.components.collaborative.dto.QueryBasedIntSuccessPayload)3 QueryBasedObjectInput (org.eclipse.sirius.components.collaborative.dto.QueryBasedObjectInput)3 IEditingContextEPackageService (org.eclipse.sirius.components.emf.services.IEditingContextEPackageService)3 QueryBasedBooleanInput (org.eclipse.sirius.components.collaborative.dto.QueryBasedBooleanInput)2 QueryBasedObjectSuccessPayload (org.eclipse.sirius.components.collaborative.dto.QueryBasedObjectSuccessPayload)2 QueryBasedObjectsInput (org.eclipse.sirius.components.collaborative.dto.QueryBasedObjectsInput)2 QueryBasedStringInput (org.eclipse.sirius.components.collaborative.dto.QueryBasedStringInput)2 EObject (org.eclipse.emf.ecore.EObject)1 QueryBasedBooleanSuccessPayload (org.eclipse.sirius.components.collaborative.dto.QueryBasedBooleanSuccessPayload)1 QueryBasedObjectsSuccessPayload (org.eclipse.sirius.components.collaborative.dto.QueryBasedObjectsSuccessPayload)1 QueryBasedStringSuccessPayload (org.eclipse.sirius.components.collaborative.dto.QueryBasedStringSuccessPayload)1 EditingContext (org.eclipse.sirius.components.emf.services.EditingContext)1