org.mule.runtime.api.message.Message.getPayload()方法的使用及代码示例

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

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

Message.getPayload介绍

[英]Gets a TypedValue with the payload of this message.
[中]获取包含此消息有效负载的TypedValue。

代码示例

代码示例来源:origin: mulesoft/mule

@Test
public void mapStreamBlockingGetNullResult() {
 CoreEvent result = just(event).transform(testProcessorReturnsNull).block();
 assertThat(result.getMessage().getPayload().getValue(), is(nullValue()));
}

代码示例来源:origin: mulesoft/mule

@Test
public void mapStreamSubscribeNullResult() throws Exception {
 CoreEvent result = just(event).transform(testProcessorReturnsNull).block();
 assertThat(result.getMessage().getPayload().getValue(), is(nullValue()));
}

代码示例来源:origin: mulesoft/mule

@Test
public void getMedicalHistory() throws Exception {
 Map<String, HealthStatus> getMedicalHistory =
   (Map<String, HealthStatus>) flowRunner("getMedicalHistory").run().getMessage().getPayload().getValue();
 assertThat(getMedicalHistory, is(notNullValue()));
 assertThat(getMedicalHistory.entrySet().size(), is(3));
 assertThat(getMedicalHistory.get("2013"), is(HEALTHY));
 assertThat(getMedicalHistory.get("2014"), is(CANCER));
 assertThat(getMedicalHistory.get("2015"), is(DEAD));
}

代码示例来源:origin: mulesoft/mule

@Test
public void nullSafeOnGroupAndPojo() throws Exception {
 TypedValue<Object> payload = flowRunner("nullSafeOnGroupAndPojo").run().getMessage().getPayload();
 Object listOfNullsafes = payload.getValue();
 assertThat(listOfNullsafes, is(instanceOf(List.class)));
 assertThat(((List<?>) listOfNullsafes).get(0), is(instanceOf(RottenFood.class)));
 assertThat(((List<?>) listOfNullsafes).get(1), is(instanceOf(RottenFood.class)));
}

代码示例来源:origin: mulesoft/mule

@Test
public void mapBlockingNullResult() throws Exception {
 CoreEvent result = testProcessorReturnsNull.process(event);
 assertThat(result.getMessage().getPayload().getValue(), is(nullValue()));
}

代码示例来源:origin: mulesoft/mule

@Test
public void alias() throws Exception {
 String alias = (String) runFlow("alias").getMessage().getPayload().getValue();
 assertThat(alias, is("Howdy!, my name is Walter White and I'm 52 years old"));
}

代码示例来源:origin: mulesoft/mule

@Test
public void connectionProviderDefaultValueSaulPhoneNumber() throws Exception {
 CoreEvent getSaulNumber = runFlow("getSaulNumber");
 assertThat(getSaulNumber.getMessage().getPayload().getValue(), is(SAUL_OFFICE_NUMBER));
}

代码示例来源:origin: mulesoft/mule

@Test
public void getGramsInStorage() throws Exception {
 int[][] gramsInStorage =
   (int[][]) flowRunner("getGramsInStorage").withPayload(new int[][] {{0, 22}, {1, 10}, {2, 30}}).run().getMessage()
     .getPayload().getValue();
 assertThat(gramsInStorage[0][0], is(0));
 assertThat(gramsInStorage[0][1], is(22));
 assertThat(gramsInStorage[1][0], is(1));
 assertThat(gramsInStorage[1][1], is(10));
 assertThat(gramsInStorage[2][0], is(2));
 assertThat(gramsInStorage[2][1], is(30));
}

代码示例来源:origin: mulesoft/mule

@Test
public void listOfMapsAsParameter() throws Exception {
 String expectedMessage = "an Apple";
 List<Map<String, String>> listOfMaps = new ArrayList<>();
 Map<String, String> map = new HashMap<>();
 map.put(Apple.class.getSimpleName(), expectedMessage);
 listOfMaps.add(map);
 CoreEvent event = flowRunner("eatComplexListOfMaps").withPayload(listOfMaps).run();
 List<Map<String, String>> result = (List<Map<String, String>>) event.getMessage().getPayload().getValue();
 assertThat(result, hasSize(1));
 assertThat(result.get(0).get(Apple.class.getSimpleName()), is(expectedMessage));
}

代码示例来源:origin: mulesoft/mule

@Test
public void nullSafeOnMap() throws Exception {
 TypedValue<Object> payload = flowRunner("nullSafeOnMap").run().getMessage().getPayload();
 Object nullSafeMap = payload.getValue();
 assertThat(nullSafeMap, is(instanceOf(Map.class)));
 assertThat(((Map) nullSafeMap).isEmpty(), is(true));
}

代码示例来源:origin: mulesoft/mule

@Test
public void operationReturnsPayloadValue() throws Exception {
 Object value = new Object();
 when(operationExecutor.execute(any(ExecutionContext.class))).thenReturn(just(value));
 Message message = messageProcessor.process(event).getMessage();
 assertThat(message, is(notNullValue()));
 assertThat(message.getPayload().getValue(), is(sameInstance(value)));
}

代码示例来源:origin: mulesoft/mule

@Test
 public void parseConnectionProviderWithAlias() throws Exception {
  Banana connection = (Banana) runFlow("alias").getMessage().getPayload().getValue();
  assertThat(connection, is(notNullValue()));
  assertThat(connection.getOrigin(), is("Brazil"));
 }
}

代码示例来源:origin: mulesoft/mule

@Test
public void testExpressionSplitterWithIteratorInput() throws Exception {
 CoreEvent result = splitter.process(muleEvent);
 List<?> values = (List<?>) result.getMessage().getPayload().getValue();
 assertThat(values.size(), is(integers.size()));
 assertListValues(values);
}

代码示例来源:origin: mulesoft/mule

@Test
public void operationWithReturnValueOnTarget() throws Exception {
 FlowRunner runner = flowRunner("sayMyNameOnTarget").withPayload(EMPTY_STRING);
 CoreEvent responseEvent = runner.run();
 assertThat(responseEvent.getMessage().getPayload().getValue(), is(EMPTY_STRING));
 Message responseMessage = (Message) responseEvent.getVariables().get("myFace").getValue();
 assertThat(responseMessage.getPayload().getValue(), is(HEISENBERG));
}

代码示例来源:origin: mulesoft/mule

@Test
 public void munitSpyNoAttributes() throws Exception {
  CoreEvent internalEvent = flowRunner("munitSpyNoAttributes").run();
  assertThat(internalEvent.getMessage().getPayload().getValue(), is(nullValue()));
  assertThat(internalEvent.getVariables().get("before"), is(nullValue()));
  assertThat(internalEvent.getVariables().get("after"), is(nullValue()));
 }
}

代码示例来源:origin: mulesoft/mule

@Test
public void operationReturnsPayloadValueWithTarget() throws Exception {
 target = TARGET_VAR;
 messageProcessor = setUpOperationMessageProcessor();
 Object value = new Object();
 when(operationExecutor.execute(any(ExecutionContext.class))).thenReturn(just(value));
 Message message = (Message) messageProcessor.process(event).getVariables().get(TARGET_VAR).getValue();
 assertThat(message, is(notNullValue()));
 assertThat(message.getPayload().getValue(), is(sameInstance(value)));
}

代码示例来源:origin: mulesoft/mule

@Test
public void returnsSingleValue() {
 byte[] value = new byte[] {};
 CoreEvent result = delegate.asReturnValue(value, operationContext);
 Message message = getOutputMessage(result);
 assertThat(message.getPayload().getValue(), is(sameInstance(value)));
 assertThat(message.getPayload().getDataType().getType().equals(byte[].class), is(true));
}

代码示例来源:origin: mulesoft/mule

@Test
public void payloadModifier() throws Exception {
 CoreEvent event = flowRunner("payloadModifier").run();
 assertThat(event.getMessage().getPayload().getValue(), is("MESSAGE"));
 assertThat(event.getVariables().get("newPayload").getValue(), is("MESSAGE"));
 assertThat(event.getVariables().get("newAttributes").getValue(), is(notNullValue()));
}

代码示例来源:origin: mulesoft/mule

@Test
 public void execute() throws Exception {
  Fruit fruit = (Fruit) flowRunner(fruitType.getSimpleName().toLowerCase() + "Ok").run().getMessage().getPayload().getValue();
  assertThat(fruit.getClass(), equalTo(fruitType));
  assertThat(fruit.isBitten(), is(true));
 }
}

代码示例来源:origin: mulesoft/mule

@Test
public void verifyProcessorInitialise() throws Exception {
 runFlow("getChain").getMessage().getPayload().getValue();
 runFlow("getChain").getMessage().getPayload().getValue();
 runFlow("getChain").getMessage().getPayload().getValue();
 int value = (int) runFlow("getCounter").getMessage().getPayload().getValue();
 assertThat(value, is(1));
}

相关文章