Search in sources :

Example 1 with FilterOptions

use of io.syndesis.common.model.filter.FilterOptions in project syndesis by syndesisio.

the class FilterITCase method shouldGetGlobalFilterOptions.

@Test
public void shouldGetGlobalFilterOptions() {
    ResponseEntity<FilterOptions> response = get("/api/v1/integrations/filters/options", FilterOptions.class, tokenRule.validToken(), HttpStatus.OK);
    FilterOptions filterOptions = response.getBody();
    Assert.assertNotNull(filterOptions);
}
Also used : FilterOptions(io.syndesis.common.model.filter.FilterOptions) Test(org.junit.Test)

Example 2 with FilterOptions

use of io.syndesis.common.model.filter.FilterOptions in project syndesis by syndesisio.

the class IntegrationHandlerTest method filterOptionsNoOutputShape.

@Test
public void filterOptionsNoOutputShape() {
    DataShape dataShape = dataShape(DataShapeKinds.NONE);
    FilterOptions options = handler.getFilterOptions(dataShape);
    assertThat(options.getPaths()).isEmpty();
}
Also used : DataShape(io.syndesis.common.model.DataShape) FilterOptions(io.syndesis.common.model.filter.FilterOptions) Test(org.junit.Test)

Example 3 with FilterOptions

use of io.syndesis.common.model.filter.FilterOptions in project syndesis by syndesisio.

the class ConnectorHandler method getFilterOptions.

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path(value = "/{connectorId}/actions/{actionId}/filters/options")
public FilterOptions getFilterOptions(@PathParam("connectorId") @ApiParam(required = true) final String connectorId, @PathParam("actionId") @ApiParam(required = true) final String actionId) {
    final FilterOptions.Builder builder = new FilterOptions.Builder().addOp(Op.DEFAULT_OPTS);
    final Connector connector = getDataManager().fetch(Connector.class, connectorId);
    if (connector == null) {
        return builder.build();
    }
    connector.findActionById(actionId).filter(ConnectorAction.class::isInstance).map(ConnectorAction.class::cast).ifPresent(action -> {
        action.getOutputDataShape().ifPresent(dataShape -> {
            final List<String> paths = inspectors.getPaths(dataShape.getKind().toString(), dataShape.getType(), dataShape.getSpecification(), dataShape.getExemplar());
            builder.addAllPaths(paths);
        });
    });
    return builder.build();
}
Also used : Connector(io.syndesis.common.model.connection.Connector) ConnectorAction(io.syndesis.common.model.action.ConnectorAction) FilterOptions(io.syndesis.common.model.filter.FilterOptions) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with FilterOptions

use of io.syndesis.common.model.filter.FilterOptions in project syndesis by syndesisio.

the class IntegrationHandlerTest method filterOptionsSimple.

@Test
public void filterOptionsSimple() {
    when(inspectors.getPaths(DataShapeKinds.JAVA.toString(), "twitter4j.Status", null, Optional.empty())).thenReturn(Arrays.asList("paramA", "paramB"));
    DataShape dataShape = dataShape(DataShapeKinds.JAVA, "twitter4j.Status");
    FilterOptions options = handler.getFilterOptions(dataShape);
    assertThat(options.getPaths()).hasSize(2).contains("paramA", "paramB");
}
Also used : DataShape(io.syndesis.common.model.DataShape) FilterOptions(io.syndesis.common.model.filter.FilterOptions) Test(org.junit.Test)

Aggregations

FilterOptions (io.syndesis.common.model.filter.FilterOptions)4 Test (org.junit.Test)3 DataShape (io.syndesis.common.model.DataShape)2 ConnectorAction (io.syndesis.common.model.action.ConnectorAction)1 Connector (io.syndesis.common.model.connection.Connector)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1