@Test public void fromJSInteropToMetadata_WithModels() { final String modelName = "LinearRegression"; final List<PMMLModelData> modelsData = new ArrayList<>(); final PMMLFieldData fieldData1Mock = PowerMockito.mock(PMMLFieldData.class); final PMMLFieldData fieldData2Mock = PowerMockito.mock(PMMLFieldData.class); PowerMockito.when(fieldData1Mock.getFieldName()).thenReturn("field1"); PowerMockito.when(fieldData1Mock.getUsageType()).thenReturn(PMMLMarshallerConverter.ACTIVE); PowerMockito.when(fieldData2Mock.getFieldName()).thenReturn("field2"); PowerMockito.when(fieldData2Mock.getUsageType()).thenReturn(PMMLMarshallerConverter.ACTIVE); final List<PMMLFieldData> fieldsData = Arrays.asList(fieldData1Mock, fieldData2Mock); final PMMLModelData pmmlModelDataMock = PowerMockito.mock(PMMLModelData.class); modelsData.add(pmmlModelDataMock); PowerMockito.when(pmmlModelDataMock.getModelName()).thenReturn(modelName); PowerMockito.when(pmmlModelDataMock.getFields()).thenReturn(fieldsData); PMMLDocumentData pmmlDocumentDataMock = PowerMockito.mock(PMMLDocumentData.class); PowerMockito.when(pmmlDocumentDataMock.getModels()).thenReturn(modelsData); PMMLDocumentMetadata metadata = PMMLMarshallerConverter.fromJSInteropToMetadata(PATH, pmmlDocumentDataMock); assertEquals(PATH, metadata.getPath()); assertEquals(UNDEFINED, metadata.getName()); assertEquals(1, metadata.getModels().size()); assertEquals(modelName, metadata.getModels().get(0).getName()); ArrayList<PMMLParameterMetadata> fields = new ArrayList<>(metadata.getModels().get(0).getInputParameters()); Collections.sort(fields, Comparator.comparing(PMMLParameterMetadata::getName)); assertEquals(2, fields.size()); assertEquals("field1", fields.get(0).getName()); assertEquals("field2", fields.get(1).getName()); }
public static PMMLDocumentMetadata fromJSInteropToMetadata(final String pmmlFilePath, final PMMLDocumentData pmmlDocumentData) { final List<PMMLModelMetadata> models = new ArrayList<>(); pmmlDocumentData.getModels().stream().forEach(pmmlModelData -> { final String modelName = pmmlModelData.getModelName(); final Set<PMMLParameterMetadata> fields = pmmlModelData.getFields().stream().filter(field -> isValidInputField(field.getUsageType())) .map(field -> new PMMLParameterMetadata(field.getFieldName())).collect(Collectors.toSet()); models.add(new PMMLModelMetadata(modelName, fields)); }); return new PMMLDocumentMetadata(pmmlFilePath, DMNImportTypes.PMML.getDefaultNamespace(), models); }
PMMLMarshallerConverter { public static PMMLDocumentMetadata fromJSInteropToMetadata(final String pmmlFilePath, final PMMLDocumentData pmmlDocumentData) { final List<PMMLModelMetadata> models = new ArrayList<>(); pmmlDocumentData.getModels().stream().forEach(pmmlModelData -> { final String modelName = pmmlModelData.getModelName(); final Set<PMMLParameterMetadata> fields = pmmlModelData.getFields().stream().filter(field -> isValidInputField(field.getUsageType())) .map(field -> new PMMLParameterMetadata(field.getFieldName())).collect(Collectors.toSet()); models.add(new PMMLModelMetadata(modelName, fields)); }); return new PMMLDocumentMetadata(pmmlFilePath, DMNImportTypes.PMML.getDefaultNamespace(), models); } }
PMMLMarshallerConverter { public static PMMLDocumentMetadata fromJSInteropToMetadata(final String pmmlFilePath, final PMMLDocumentData pmmlDocumentData) { final List<PMMLModelMetadata> models = new ArrayList<>(); pmmlDocumentData.getModels().stream().forEach(pmmlModelData -> { final String modelName = pmmlModelData.getModelName(); final Set<PMMLParameterMetadata> fields = pmmlModelData.getFields().stream().filter(field -> isValidInputField(field.getUsageType())) .map(field -> new PMMLParameterMetadata(field.getFieldName())).collect(Collectors.toSet()); models.add(new PMMLModelMetadata(modelName, fields)); }); return new PMMLDocumentMetadata(pmmlFilePath, DMNImportTypes.PMML.getDefaultNamespace(), models); } private  PMMLMarshallerConverter(); }
PMMLMarshallerConverter { public static PMMLDocumentMetadata fromJSInteropToMetadata(final String pmmlFilePath, final PMMLDocumentData pmmlDocumentData) { final List<PMMLModelMetadata> models = new ArrayList<>(); pmmlDocumentData.getModels().stream().forEach(pmmlModelData -> { final String modelName = pmmlModelData.getModelName(); final Set<PMMLParameterMetadata> fields = pmmlModelData.getFields().stream().filter(field -> isValidInputField(field.getUsageType())) .map(field -> new PMMLParameterMetadata(field.getFieldName())).collect(Collectors.toSet()); models.add(new PMMLModelMetadata(modelName, fields)); }); return new PMMLDocumentMetadata(pmmlFilePath, DMNImportTypes.PMML.getDefaultNamespace(), models); } private  PMMLMarshallerConverter(); static PMMLDocumentMetadata fromJSInteropToMetadata(final String pmmlFilePath,
                                                               final PMMLDocumentData pmmlDocumentData); }
PMMLMarshallerConverter { public static PMMLDocumentMetadata fromJSInteropToMetadata(final String pmmlFilePath, final PMMLDocumentData pmmlDocumentData) { final List<PMMLModelMetadata> models = new ArrayList<>(); pmmlDocumentData.getModels().stream().forEach(pmmlModelData -> { final String modelName = pmmlModelData.getModelName(); final Set<PMMLParameterMetadata> fields = pmmlModelData.getFields().stream().filter(field -> isValidInputField(field.getUsageType())) .map(field -> new PMMLParameterMetadata(field.getFieldName())).collect(Collectors.toSet()); models.add(new PMMLModelMetadata(modelName, fields)); }); return new PMMLDocumentMetadata(pmmlFilePath, DMNImportTypes.PMML.getDefaultNamespace(), models); } private  PMMLMarshallerConverter(); static PMMLDocumentMetadata fromJSInteropToMetadata(final String pmmlFilePath,
                                                               final PMMLDocumentData pmmlDocumentData); static final String ACTIVE; }