org.kie.server.api.marshalling.Marshaller.marshall()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中org.kie.server.api.marshalling.Marshaller.marshall()方法的一些代码示例,展示了Marshaller.marshall()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Marshaller.marshall()方法的具体详情如下:
包路径:org.kie.server.api.marshalling.Marshaller
类名称:Marshaller
方法名:marshall

Marshaller.marshall介绍

暂无

代码示例

代码示例来源:origin: org.kie.server/kie-server-controller-client

protected String serialize(Object object) {
  if (object == null) {
    return "";
  }
  try {
    return marshaller.marshall( object );
  } catch ( MarshallingException e ) {
    throw new RuntimeException( "Error while serializing request data!", e );
  }
}

代码示例来源:origin: org.kie.server/kie-server-controller-websocket-client

protected String serialize(Object object) {
  if (object == null) {
    return "";
  }
  try {
    return marshaller.marshall(object);
  } catch ( MarshallingException e ) {
    throw new IllegalStateException( "Error while serializing request data!", e );
  }
}

代码示例来源:origin: org.kie/kie-server-client

private String serialize(Object object) {
  try {
    return marshaller.marshall( object );
  } catch ( MarshallingException e ) {
    throw new KieServicesException( "Error while serializing request data!", e );
  }
}

代码示例来源:origin: org.kie.server/kie-server-services-common

protected String serialize(Object object) {
  if (object == null) {
    return "";
  }
  try {
    return MarshallerFactory.getMarshaller(MarshallingFormat.JSON, this.getClass().getClassLoader()).marshall(object);
  } catch ( MarshallingException e ) {
    throw new IllegalStateException( "Error while serializing request data!", e );
  }
}

代码示例来源:origin: org.kie.server/kie-server-client

protected String serialize(Object object) {
  if (object == null) {
    return "";
  }
  try {
    return marshaller.marshall( object );
  } catch ( MarshallingException e ) {
    throw new KieServicesException( "Error while serializing request data!", e );
  }
}

代码示例来源:origin: org.kie.server/kie-server-services-common

public String marshal(String marshallingFormat, Object entity) {
  MarshallingFormat format = getFormat(marshallingFormat);
  if (format == null) {
    throw new IllegalArgumentException("Unknown marshalling format " + marshallingFormat);
  }
  Marshaller marshaller = serverMarshallers.get(format);
  if (marshaller == null) {
    marshaller = MarshallerFactory.getMarshaller(getExtraClasses(registry), format, this.getClass().getClassLoader());
    serverMarshallers.put(format, marshaller);
  }
  return marshaller.marshall(entity);
}

代码示例来源:origin: kiegroup/droolsjbpm-integration

private void verifyMarshallingRoundTrip( Marshaller marshaller, Object inputObject ) {
  String rawContent = marshaller.marshall( inputObject );
  logger.info(rawContent);
  Object testObjectAfterMarshallingTurnAround = marshaller.unmarshall( rawContent, inputObject.getClass() );
  Assertions.assertThat( testObjectAfterMarshallingTurnAround ).isEqualTo( inputObject );
}

代码示例来源:origin: kiegroup/droolsjbpm-integration

private void verifyMarshallingRoundTrip(Marshaller marshaller, Object inputObject) {
  String rawContent = marshaller.marshall(inputObject);
  Object testObjectAfterMarshallingTurnAround = marshaller.unmarshall(rawContent, inputObject.getClass());
  Assertions.assertThat(inputObject).isEqualTo(testObjectAfterMarshallingTurnAround);
}

代码示例来源:origin: kiegroup/droolsjbpm-integration

@Test
public void testMarshallFormatDateObject() throws ParseException {
  System.setProperty("org.kie.server.json.format.date", "true");
  Date date = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSSZ").parse("2018-01-01T10:00:00.000+0100");
  String expectedString = "\"2018-01-01";
  Marshaller marshaller = MarshallerFactory.getMarshaller( MarshallingFormat.JSON, getClass().getClassLoader() );
  
  String dateObjectString = marshaller.marshall( date );
  assertNotNull( dateObjectString );
  assertTrue( dateObjectString.startsWith(expectedString) );
      
}

代码示例来源:origin: kiegroup/droolsjbpm-integration

@Test
public void testJsonMarshalling() {
 final String result = jsonMarshaller.marshall( BEAN );
 assertEquals( JSON, result ); // TODO: jsonpath?
}

代码示例来源:origin: org.kie/kie-server-services

@Test
public void testMarshallInsertObjectCommand() {
  String xmlCommand = "<insert>\n" +
            "  <string>String value</string>\n" +
            "</insert>";
  InsertObjectCommand command = marshaller.unmarshall( xmlCommand, InsertObjectCommand.class );
  assertEquals( "String value", command.getObject().toString() );
  assertEquals( xmlCommand, marshaller.marshall( command ) );
}

代码示例来源:origin: org.kie/kie-server-services

@Test
public void testMarshallModifyCommand() {
  String xmlCommand = "<modify fact-handle=\"0:234:345:456:567:789\">\n" +
            "  <set accessor=\"age\" value=\"30\"/>\n" +
            "</modify>";
  ModifyCommand command = marshaller.unmarshall(xmlCommand, ModifyCommand.class);
  assertEquals(1, command.getSetters().size());
  assertEquals("<modify fact-handle=\"0:234:345:456:567:789:NON_TRAIT\">\n" +
      "  <set accessor=\"age\" value=\"30\"/>\n" +
      "</modify>", marshaller.marshall(command));
}

代码示例来源:origin: org.kie/kie-server-services

@Test
public void testMarshallInsertElementsCommand() {
  String xmlCommand = "<insert-elements>\n" +
      "  <string>test1</string>\n" +
      "  <string>test2</string>\n" +
      "</insert-elements>";
  InsertElementsCommand command = marshaller.unmarshall(xmlCommand, InsertElementsCommand.class);
  assertEquals(2, command.getObjects().size());
  assertEquals(xmlCommand, marshaller.marshall(command));
}

代码示例来源:origin: org.kie/kie-server-services

@Test
public void testMarshallFireAllRulesCommand() {
  String xmlCommand = "<fire-all-rules max=\"10\" out-identifier=\"result\"/>";
  FireAllRulesCommand command = marshaller.unmarshall(xmlCommand, FireAllRulesCommand.class);
  assertEquals(10, command.getMax());
  assertEquals(xmlCommand, marshaller.marshall(command));
}

代码示例来源:origin: org.kie/kie-server-services

@Test
public void testMarshallGetObjectCommand() {
  String xmlCommand = "<get-object fact-handle=\"0:234:345:456:567:789\" out-identifier=\"test\"/>";
  GetObjectCommand command = marshaller.unmarshall(xmlCommand, GetObjectCommand.class);
  assertEquals("test", command.getOutIdentifier());
  assertEquals("<get-object fact-handle=\"0:234:345:456:567:789:NON_TRAIT\" out-identifier=\"test\"/>", marshaller.marshall(command));
}

代码示例来源:origin: org.kie/kie-server-services

@Test
public void testMarshallStartProcessCommand() {
  String xmlCommand = "<start-process processId=\"org.drools.task.processOne\" out-identifier=\"id\"/>";
  StartProcessCommand command = marshaller.unmarshall(xmlCommand, StartProcessCommand.class);
  assertEquals("org.drools.task.processOne", command.getProcessId());
  assertEquals(xmlCommand, marshaller.marshall(command));
}

代码示例来源:origin: org.kie/kie-server-services

@Test
public void testMarshallGetObjectsCommand() {
  String xmlCommand = "<get-objects out-identifier=\"objects\"/>";
  GetObjectsCommand command = marshaller.unmarshall(xmlCommand, GetObjectsCommand.class);
  assertEquals("objects", command.getOutIdentifier());
  assertEquals(xmlCommand, marshaller.marshall(command));
}

代码示例来源:origin: org.kie/kie-server-services

@Test
@Ignore("Set focus command not yet supported")
public void testMarshallAgendaGroupSetFocusCommand() {
  String xmlCommand = "<agenda-group-set-focus name=\"my-agenda-group\"/>";
  AgendaGroupSetFocusCommand command = marshaller.unmarshall(xmlCommand, AgendaGroupSetFocusCommand.class);
  assertEquals("my-agenda-group", command.getName());
  assertEquals(xmlCommand, marshaller.marshall(command));
}

代码示例来源:origin: org.kie/kie-server-services

@Test
public void testMarshallRetractCommand() {
  String xmlCommand = "<retract fact-handle=\"0:234:345:456:567:789\"/>";
  DeleteCommand command = marshaller.unmarshall( xmlCommand, DeleteCommand.class );
  assertEquals( "0:234:345:456:567:789:NON_TRAIT", command.getFactHandle().toExternalForm() );
  assertEquals( "<retract fact-handle=\"0:234:345:456:567:789:NON_TRAIT\"/>", marshaller.marshall( command ) );
}

代码示例来源:origin: kiegroup/droolsjbpm-integration

@SuppressWarnings("unchecked")
  private <S extends Score<?>> S marshallUnmarshallScore(S toBeMarshalled) {
    ScoreWrapper wrapper = new ScoreWrapper(toBeMarshalled);

    SolverInstance instance = new SolverInstance();
    instance.setScoreWrapper(wrapper);

    String marshalledSolver = marshaller.marshall(instance);
    SolverInstance result = marshaller.unmarshall(marshalledSolver, SolverInstance.class);

    return (S) result.getScoreWrapper().toScore();
  }
}

相关文章