use of com.linkedin.restli.examples.greetings.api.ToneArray in project rest.li by linkedin.
the class TestActionsResource method testArrayTypesOnActions.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testArrayTypesOnActions(RootBuilderWrapper<?, ?> builders) throws RemoteInvocationException {
//Record template array
MessageArray inputMessageArray = new MessageArray();
inputMessageArray.add(new Message().setId("My Message Id").setMessage("My Message"));
inputMessageArray.add(new Message().setId("My Message Id 2").setMessage("My Message 2"));
Request<MessageArray> messageArrayRequest = builders.<MessageArray>action("EchoMessageArray").setActionParam("Messages", inputMessageArray).build();
MessageArray messageArray = getClient().sendRequest(messageArrayRequest).getResponse().getEntity();
Assert.assertEquals(messageArray.get(0).getId(), "My Message Id");
Assert.assertEquals(messageArray.get(0).getMessage(), "My Message");
Assert.assertEquals(messageArray.get(1).getId(), "My Message Id 2");
Assert.assertEquals(messageArray.get(1).getMessage(), "My Message 2");
//Primitive type array
StringArray inputStringArray = new StringArray();
inputStringArray.add("message1");
inputStringArray.add("message2");
Request<StringArray> stringArrayRequest = builders.<StringArray>action("EchoStringArray").setActionParam("Strings", inputStringArray).build();
StringArray stringArray = getClient().sendRequest(stringArrayRequest).getResponse().getEntity();
Assert.assertEquals(stringArray.get(0), "message1");
Assert.assertEquals(stringArray.get(1), "message2");
//Enum array
ToneArray inputTonesArray = new ToneArray();
inputTonesArray.add(Tone.SINCERE);
inputTonesArray.add(Tone.FRIENDLY);
Request<ToneArray> toneArrayRequest = builders.<ToneArray>action("EchoToneArray").setActionParam("Tones", inputTonesArray).build();
ToneArray tones = getClient().sendRequest(toneArrayRequest).getResponse().getEntity();
Assert.assertEquals(tones.get(0), Tone.SINCERE);
Assert.assertEquals(tones.get(1), Tone.FRIENDLY);
}
Aggregations