@Test public void shouldDetermineAddingResponseConverterRobustly() { assertThat(ResponseCustomizer.isUnifiedDataShape(null)).isFalse(); assertThat(ResponseCustomizer.isUnifiedDataShape(new DataShape.Builder().build())).isFalse(); assertThat(ResponseCustomizer.isUnifiedDataShape(new DataShape.Builder().kind(DataShapeKinds.JAVA).build())).isFalse(); assertThat(ResponseCustomizer.isUnifiedDataShape(new DataShape.Builder().kind(DataShapeKinds.JSON_SCHEMA).build())).isFalse(); assertThat(ResponseCustomizer.isUnifiedDataShape(new DataShape.Builder().kind(DataShapeKinds.JSON_SCHEMA).specification("xyz").build())).isFalse(); assertThat(ResponseCustomizer.isUnifiedDataShape(new DataShape.Builder().kind(DataShapeKinds.JSON_SCHEMA).specification("{}").build())).isFalse(); }
static boolean isUnifiedDataShape(final DataShape dataShape) { if (dataShape == null || dataShape.getKind() != DataShapeKinds.JSON_SCHEMA) { return false; } final String specification = dataShape.getSpecification(); if (ObjectHelper.isEmpty(specification)) { return false; } final JsonNode jsonSchema; try { jsonSchema = PayloadConverterBase.MAPPER.readTree(specification); } catch (final IOException e) { LOG.warn("Unable to parse data shape as a JSON: {}", e.getMessage()); LOG.debug("Failed parsing JSON datashape: `{}`", specification, e); return false; } final JsonNode id = jsonSchema.get("$id"); return !isNullNode(id) && "io:syndesis:wrapped".equals(id.asText()); }
ResponseCustomizer implements ComponentProxyCustomizer, OutputDataShapeAware { static boolean isUnifiedDataShape(final DataShape dataShape) { if (dataShape == null || dataShape.getKind() != DataShapeKinds.JSON_SCHEMA) { return false; } final String specification = dataShape.getSpecification(); if (ObjectHelper.isEmpty(specification)) { return false; } final JsonNode jsonSchema; try { jsonSchema = PayloadConverterBase.MAPPER.readTree(specification); } catch (final IOException e) { LOG.warn("Unable to parse data shape as a JSON: {}", e.getMessage()); LOG.debug("Failed parsing JSON datashape: `{}`", specification, e); return false; } final JsonNode id = jsonSchema.get("$id"); return !isNullNode(id) && "io:syndesis:wrapped".equals(id.asText()); } }
ResponseCustomizer implements ComponentProxyCustomizer, OutputDataShapeAware { static boolean isUnifiedDataShape(final DataShape dataShape) { if (dataShape == null || dataShape.getKind() != DataShapeKinds.JSON_SCHEMA) { return false; } final String specification = dataShape.getSpecification(); if (ObjectHelper.isEmpty(specification)) { return false; } final JsonNode jsonSchema; try { jsonSchema = PayloadConverterBase.MAPPER.readTree(specification); } catch (final IOException e) { LOG.warn("Unable to parse data shape as a JSON: {}", e.getMessage()); LOG.debug("Failed parsing JSON datashape: `{}`", specification, e); return false; } final JsonNode id = jsonSchema.get("$id"); return !isNullNode(id) && "io:syndesis:wrapped".equals(id.asText()); }  }
ResponseCustomizer implements ComponentProxyCustomizer, OutputDataShapeAware { static boolean isUnifiedDataShape(final DataShape dataShape) { if (dataShape == null || dataShape.getKind() != DataShapeKinds.JSON_SCHEMA) { return false; } final String specification = dataShape.getSpecification(); if (ObjectHelper.isEmpty(specification)) { return false; } final JsonNode jsonSchema; try { jsonSchema = PayloadConverterBase.MAPPER.readTree(specification); } catch (final IOException e) { LOG.warn("Unable to parse data shape as a JSON: {}", e.getMessage()); LOG.debug("Failed parsing JSON datashape: `{}`", specification, e); return false; } final JsonNode id = jsonSchema.get("$id"); return !isNullNode(id) && "io:syndesis:wrapped".equals(id.asText()); }  @Override void customize(final ComponentProxyComponent component, final Map<String, Object> options); @Override DataShape getOutputDataShape(); @Override void setOutputDataShape(final DataShape dataShape); }
ResponseCustomizer implements ComponentProxyCustomizer, OutputDataShapeAware { static boolean isUnifiedDataShape(final DataShape dataShape) { if (dataShape == null || dataShape.getKind() != DataShapeKinds.JSON_SCHEMA) { return false; } final String specification = dataShape.getSpecification(); if (ObjectHelper.isEmpty(specification)) { return false; } final JsonNode jsonSchema; try { jsonSchema = PayloadConverterBase.MAPPER.readTree(specification); } catch (final IOException e) { LOG.warn("Unable to parse data shape as a JSON: {}", e.getMessage()); LOG.debug("Failed parsing JSON datashape: `{}`", specification, e); return false; } final JsonNode id = jsonSchema.get("$id"); return !isNullNode(id) && "io:syndesis:wrapped".equals(id.asText()); }  @Override void customize(final ComponentProxyComponent component, final Map<String, Object> options); @Override DataShape getOutputDataShape(); @Override void setOutputDataShape(final DataShape dataShape);  }