Search in sources :

Example 1 with ToneArray

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);
}
Also used : ToneArray(com.linkedin.restli.examples.greetings.api.ToneArray) Message(com.linkedin.restli.examples.greetings.api.Message) StringArray(com.linkedin.data.template.StringArray) MessageArray(com.linkedin.restli.examples.greetings.api.MessageArray) Test(org.testng.annotations.Test)

Aggregations

StringArray (com.linkedin.data.template.StringArray)1 Message (com.linkedin.restli.examples.greetings.api.Message)1 MessageArray (com.linkedin.restli.examples.greetings.api.MessageArray)1 ToneArray (com.linkedin.restli.examples.greetings.api.ToneArray)1 Test (org.testng.annotations.Test)1