use of org.kie.api.pmml.PMMLRequestData in project drools by kiegroup.
the class PMMLCommandExecutorImpl method getCleanedRequestData.
/**
* Return a <b>new</b> <code>PMMLRequestData</code> with the values of the original <code>PMMLRequestData</code> restored to their actual type.
*
* Needed because <code>JSONMarshallerPMMLParamInfo</code> convert all of them to <code>String</code>
*
* @see <a href="https://github.com/kiegroup/droolsjbpm-integration/blob/master/kie-server-parent/kie-server-api/src/main/java/org/kie/server/api/marshalling/json/JSONMarshallerPMMLParamInfo.java#L67">JSONMarshallerPMMLParamInfo.PMMLParamSerializer.serialize(ParameterInfo, JsonGenerator, SerializerProvider)</a>
* @param source
* @return
*/
@SuppressWarnings("rawtype")
protected PMMLRequestData getCleanedRequestData(PMMLRequestData source) {
final PMMLRequestData toReturn = new PMMLRequestData();
toReturn.setSource(source.getSource());
toReturn.setCorrelationId(source.getCorrelationId());
toReturn.setModelName(source.getModelName());
source.getRequestParams().forEach(parameterInfo -> {
Object value = ConverterTypeUtil.convert(parameterInfo.getType(), parameterInfo.getValue());
ParameterInfo<?> toAdd = new ParameterInfo(parameterInfo.getCorrelationId(), parameterInfo.getName(), parameterInfo.getType(), value);
toReturn.addRequestParam(toAdd);
});
return toReturn;
}
use of org.kie.api.pmml.PMMLRequestData in project drools by kiegroup.
the class PMMLCommandExecutorImplTest method validateNoModelName.
@Test(expected = KiePMMLException.class)
public void validateNoModelName() {
PMMLRequestData pmmlRequestData = new PMMLRequestData();
pmmlRequestData.setSource("source");
PMMLCommandExecutorImpl cmdExecutor = new PMMLCommandExecutorImpl();
cmdExecutor.validate(pmmlRequestData);
}
use of org.kie.api.pmml.PMMLRequestData in project drools by kiegroup.
the class PMMLCommandExecutorImplTest method getPMMLRequestData.
@SuppressWarnings("rawtype")
private PMMLRequestData getPMMLRequestData() {
PMMLRequestData toReturn = new PMMLRequestData();
String correlationId = "correlationId";
toReturn.setSource("source");
toReturn.setCorrelationId(correlationId);
toReturn.setModelName("modelName");
List<Class> classList = Arrays.asList(Integer.class, Double.class, Boolean.class, String.class);
classList.forEach(aClass -> {
Object value = getRandomValue(aClass.getSimpleName()).toString();
ParameterInfo<?> toAdd = new ParameterInfo(correlationId, RandomStringUtils.random(4, true, false), aClass, value);
toReturn.addRequestParam(toAdd);
});
return toReturn;
}
use of org.kie.api.pmml.PMMLRequestData in project drools by kiegroup.
the class PMMLCommandExecutorImplTest method getCleanedRequestData.
@Test()
public void getCleanedRequestData() {
PMMLRequestData pmmlRequestData = getPMMLRequestData();
PMMLCommandExecutorImpl cmdExecutor = new PMMLCommandExecutorImpl();
PMMLRequestData retrieved = cmdExecutor.getCleanedRequestData(pmmlRequestData);
assertNotNull(retrieved);
assertEquals(pmmlRequestData.getSource(), retrieved.getSource());
assertEquals(pmmlRequestData.getCorrelationId(), retrieved.getCorrelationId());
assertEquals(pmmlRequestData.getModelName(), retrieved.getModelName());
Map<String, ParameterInfo> requestParams = retrieved.getMappedRequestParams();
pmmlRequestData.getRequestParams().forEach(parameterInfo -> {
assertTrue(requestParams.containsKey(parameterInfo.getName()));
ParameterInfo cleaned = requestParams.get(parameterInfo.getName());
assertEquals(parameterInfo.getName(), cleaned.getName());
assertEquals(parameterInfo.getCorrelationId(), cleaned.getCorrelationId());
assertEquals(parameterInfo.getType(), cleaned.getType());
assertEquals(parameterInfo.getValue(), cleaned.getValue().toString());
assertEquals(cleaned.getType(), cleaned.getValue().getClass());
});
}
use of org.kie.api.pmml.PMMLRequestData in project drools by kiegroup.
the class PMMLCommandExecutorImplTest method validateNoSource.
@Test(expected = KiePMMLException.class)
public void validateNoSource() {
PMMLRequestData pmmlRequestData = new PMMLRequestData();
pmmlRequestData.setModelName("modelName");
PMMLCommandExecutorImpl cmdExecutor = new PMMLCommandExecutorImpl();
cmdExecutor.validate(pmmlRequestData);
}
Aggregations