@Test public void generateJavaCollectionInspectionTest() throws Exception { DataShape source = new DataShape.Builder() .type(MyShape.class.getTypeName()) .kind(DataShapeKinds.JAVA) .collectionType(CollectionType.LIST.value()) .collectionClassName(ArrayList.class.getName()) .build(); DataShape enriched = GenerateConnectorInspectionsMojo.generateInspections(new URL[0], source); assertThat(enriched.getSpecification()).isNotEmpty(); JavaClass clazz = io.atlasmap.v2.Json.mapper().readValue(enriched.getSpecification(), JavaClass.class); assertThat(clazz.getCollectionClassName()).isEqualTo(ArrayList.class.getName()); assertThat(clazz.getCollectionType()).isEqualTo(CollectionType.LIST); }
private List<ConnectorAction> generateInspections(Connector connector) throws IOException, DependencyResolutionRequiredException, ClassNotFoundException { final List<ConnectorAction> actions = new ArrayList<>(); for (ConnectorAction action : connector.getActions()) { Optional<DataShape> inputDataShape = action.getDescriptor().getInputDataShape(); Optional<DataShape> outputDataShape = action.getDescriptor().getOutputDataShape(); if (inputDataShape.isPresent()) { inputDataShape = Optional.of(generateInspections(connector, inputDataShape.get())); } if (outputDataShape.isPresent()) { outputDataShape = Optional.of(generateInspections(connector, outputDataShape.get())); } if (inputDataShape.isPresent() || outputDataShape.isPresent()) { ConnectorDescriptor descriptor = new ConnectorDescriptor.Builder() .createFrom(action.getDescriptor()) .inputDataShape(inputDataShape) .outputDataShape(outputDataShape) .build(); action = new ConnectorAction.Builder() .createFrom(action) .descriptor(descriptor) .build(); } actions.add(action); } return actions; }
GenerateConnectorInspectionsMojo extends AbstractMojo { private List<ConnectorAction> generateInspections(Connector connector) throws IOException, DependencyResolutionRequiredException, ClassNotFoundException { final List<ConnectorAction> actions = new ArrayList<>(); for (ConnectorAction action : connector.getActions()) { Optional<DataShape> inputDataShape = action.getDescriptor().getInputDataShape(); Optional<DataShape> outputDataShape = action.getDescriptor().getOutputDataShape(); if (inputDataShape.isPresent()) { inputDataShape = Optional.of(generateInspections(connector, inputDataShape.get())); } if (outputDataShape.isPresent()) { outputDataShape = Optional.of(generateInspections(connector, outputDataShape.get())); } if (inputDataShape.isPresent() || outputDataShape.isPresent()) { ConnectorDescriptor descriptor = new ConnectorDescriptor.Builder() .createFrom(action.getDescriptor()) .inputDataShape(inputDataShape) .outputDataShape(outputDataShape) .build(); action = new ConnectorAction.Builder() .createFrom(action) .descriptor(descriptor) .build(); } actions.add(action); } return actions; } }
GenerateConnectorInspectionsMojo extends AbstractMojo { private List<ConnectorAction> generateInspections(Connector connector) throws IOException, DependencyResolutionRequiredException, ClassNotFoundException { final List<ConnectorAction> actions = new ArrayList<>(); for (ConnectorAction action : connector.getActions()) { Optional<DataShape> inputDataShape = action.getDescriptor().getInputDataShape(); Optional<DataShape> outputDataShape = action.getDescriptor().getOutputDataShape(); if (inputDataShape.isPresent()) { inputDataShape = Optional.of(generateInspections(connector, inputDataShape.get())); } if (outputDataShape.isPresent()) { outputDataShape = Optional.of(generateInspections(connector, outputDataShape.get())); } if (inputDataShape.isPresent() || outputDataShape.isPresent()) { ConnectorDescriptor descriptor = new ConnectorDescriptor.Builder() .createFrom(action.getDescriptor()) .inputDataShape(inputDataShape) .outputDataShape(outputDataShape) .build(); action = new ConnectorAction.Builder() .createFrom(action) .descriptor(descriptor) .build(); } actions.add(action); } return actions; } GenerateConnectorInspectionsMojo(); }
GenerateConnectorInspectionsMojo extends AbstractMojo { private List<ConnectorAction> generateInspections(Connector connector) throws IOException, DependencyResolutionRequiredException, ClassNotFoundException { final List<ConnectorAction> actions = new ArrayList<>(); for (ConnectorAction action : connector.getActions()) { Optional<DataShape> inputDataShape = action.getDescriptor().getInputDataShape(); Optional<DataShape> outputDataShape = action.getDescriptor().getOutputDataShape(); if (inputDataShape.isPresent()) { inputDataShape = Optional.of(generateInspections(connector, inputDataShape.get())); } if (outputDataShape.isPresent()) { outputDataShape = Optional.of(generateInspections(connector, outputDataShape.get())); } if (inputDataShape.isPresent() || outputDataShape.isPresent()) { ConnectorDescriptor descriptor = new ConnectorDescriptor.Builder() .createFrom(action.getDescriptor()) .inputDataShape(inputDataShape) .outputDataShape(outputDataShape) .build(); action = new ConnectorAction.Builder() .createFrom(action) .descriptor(descriptor) .build(); } actions.add(action); } return actions; } GenerateConnectorInspectionsMojo(); @Override void execute(); JsonNode validateWithSchema(File jsonFile); static DataShape generateInspections(URL[] classpath, DataShape shape); static JavaClass inspect(URL[] classpath, DataShape shape); }
GenerateConnectorInspectionsMojo extends AbstractMojo { private List<ConnectorAction> generateInspections(Connector connector) throws IOException, DependencyResolutionRequiredException, ClassNotFoundException { final List<ConnectorAction> actions = new ArrayList<>(); for (ConnectorAction action : connector.getActions()) { Optional<DataShape> inputDataShape = action.getDescriptor().getInputDataShape(); Optional<DataShape> outputDataShape = action.getDescriptor().getOutputDataShape(); if (inputDataShape.isPresent()) { inputDataShape = Optional.of(generateInspections(connector, inputDataShape.get())); } if (outputDataShape.isPresent()) { outputDataShape = Optional.of(generateInspections(connector, outputDataShape.get())); } if (inputDataShape.isPresent() || outputDataShape.isPresent()) { ConnectorDescriptor descriptor = new ConnectorDescriptor.Builder() .createFrom(action.getDescriptor()) .inputDataShape(inputDataShape) .outputDataShape(outputDataShape) .build(); action = new ConnectorAction.Builder() .createFrom(action) .descriptor(descriptor) .build(); } actions.add(action); } return actions; } GenerateConnectorInspectionsMojo(); @Override void execute(); JsonNode validateWithSchema(File jsonFile); static DataShape generateInspections(URL[] classpath, DataShape shape); static JavaClass inspect(URL[] classpath, DataShape shape);  }