Search in sources :

Example 16 with StringMap

use of com.linkedin.data.template.StringMap in project rest.li by linkedin.

the class TestParseqBasedFluentClientApi method testCollectionActionWithNoReturn.

@Test
public void testCollectionActionWithNoReturn() throws Exception {
    Greetings greetings = new GreetingsFluentClient(_parSeqRestliClient, _parSeqUnitTestHelper.getEngine());
    CompletableFuture<Void> stage = greetings.anotherAction(param -> param.setBitfield(new BooleanArray()).setRequest(new TransferOwnershipRequest()).setSomeString("").setStringMap(new StringMap())).toCompletableFuture();
    Assert.assertNull(stage.get(5000, TimeUnit.MILLISECONDS));
    assert (!stage.isCompletedExceptionally());
}
Also used : ComplexKeysSubFluentClient(com.linkedin.restli.examples.greetings.client.ComplexKeysSubFluentClient) Arrays(java.util.Arrays) CollectionResponse(com.linkedin.restli.common.CollectionResponse) Date(java.util.Date) UpdateStatus(com.linkedin.restli.common.UpdateStatus) Test(org.testng.annotations.Test) AssociationsSubFluentClient(com.linkedin.restli.examples.greetings.client.AssociationsSubFluentClient) GreetingFluentClient(com.linkedin.restli.examples.greetings.client.GreetingFluentClient) AssociationsAssociationsSubFluentClient(com.linkedin.restli.examples.greetings.client.AssociationsAssociationsSubFluentClient) TransferOwnershipRequest(com.linkedin.restli.examples.groups.api.TransferOwnershipRequest) Groups(com.linkedin.restli.examples.groups.client.Groups) PatchGenerator(com.linkedin.restli.client.util.PatchGenerator) EntityResponse(com.linkedin.restli.common.EntityResponse) Map(java.util.Map) CreateIdEntityStatus(com.linkedin.restli.common.CreateIdEntityStatus) CustomLong(com.linkedin.restli.examples.custom.types.CustomLong) CreateIdStatus(com.linkedin.restli.common.CreateIdStatus) BatchfindersFluentClient(com.linkedin.restli.examples.greetings.client.BatchfindersFluentClient) AssociationAltKey(com.linkedin.restli.examples.greetings.client.AssociationAltKey) MessageCriteriaArray(com.linkedin.restli.examples.greetings.api.MessageCriteriaArray) ComplexResourceKey(com.linkedin.restli.common.ComplexResourceKey) Greetings(com.linkedin.restli.examples.greetings.client.Greetings) BeforeClass(org.testng.annotations.BeforeClass) Set(java.util.Set) Collectors(java.util.stream.Collectors) Associations(com.linkedin.restli.examples.greetings.client.Associations) GroupsFluentClient(com.linkedin.restli.examples.groups.client.GroupsFluentClient) ParSeqRestliClientConfigBuilder(com.linkedin.restli.client.ParSeqRestliClientConfigBuilder) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) ParSeqRestliClientBuilder(com.linkedin.restli.client.ParSeqRestliClientBuilder) Actions(com.linkedin.restli.examples.greetings.client.Actions) CreateGreeting(com.linkedin.restli.examples.greetings.client.CreateGreeting) SubgreetingsFluentClient(com.linkedin.restli.examples.greetings.client.SubgreetingsFluentClient) ComplexKeys(com.linkedin.restli.examples.greetings.client.ComplexKeys) TwoPartKey(com.linkedin.restli.examples.greetings.api.TwoPartKey) AssociationsAssociationsFluentClient(com.linkedin.restli.examples.greetings.client.AssociationsAssociationsFluentClient) MessageCriteria(com.linkedin.restli.examples.greetings.api.MessageCriteria) AssociationsFluentClient(com.linkedin.restli.examples.greetings.client.AssociationsFluentClient) GreetingsFluentClient(com.linkedin.restli.examples.greetings.client.GreetingsFluentClient) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) BooleanArray(com.linkedin.data.template.BooleanArray) ArrayList(java.util.ArrayList) CustomTypes2(com.linkedin.restli.examples.greetings.client.CustomTypes2) HashSet(java.util.HashSet) PatchRequest(com.linkedin.restli.common.PatchRequest) CustomTypes3(com.linkedin.restli.examples.greetings.client.CustomTypes3) CustomTypes3FluentClient(com.linkedin.restli.examples.greetings.client.CustomTypes3FluentClient) CustomTypes2FluentClient(com.linkedin.restli.examples.greetings.client.CustomTypes2FluentClient) Assert(org.testng.Assert) UpdateEntityStatus(com.linkedin.restli.common.UpdateEntityStatus) StringMap(com.linkedin.data.template.StringMap) RestLiResponseException(com.linkedin.restli.client.RestLiResponseException) Greeting(com.linkedin.restli.examples.greetings.api.Greeting) ParSeqUnitTestHelper(com.linkedin.parseq.ParSeqUnitTestHelper) ComplexKeysFluentClient(com.linkedin.restli.examples.greetings.client.ComplexKeysFluentClient) Tone(com.linkedin.restli.examples.greetings.api.Tone) PartialUpdateGreetingFluentClient(com.linkedin.restli.examples.greetings.client.PartialUpdateGreetingFluentClient) IdEntityResponse(com.linkedin.restli.common.IdEntityResponse) AfterClass(org.testng.annotations.AfterClass) ActionsFluentClient(com.linkedin.restli.examples.greetings.client.ActionsFluentClient) BatchFinderCriteriaResult(com.linkedin.restli.common.BatchFinderCriteriaResult) PartialUpdateGreeting(com.linkedin.restli.examples.greetings.client.PartialUpdateGreeting) GreetingCriteria(com.linkedin.restli.examples.greetings.api.GreetingCriteria) CompoundKey(com.linkedin.restli.common.CompoundKey) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) CreateGreetingFluentClient(com.linkedin.restli.examples.greetings.client.CreateGreetingFluentClient) ParSeqRestliClient(com.linkedin.restli.client.ParSeqRestliClient) BatchCollectionResponse(com.linkedin.restli.common.BatchCollectionResponse) HttpStatus(com.linkedin.restli.common.HttpStatus) AssociationAltKeyFluentClient(com.linkedin.restli.examples.greetings.client.AssociationAltKeyFluentClient) Message(com.linkedin.restli.examples.greetings.api.Message) Batchfinders(com.linkedin.restli.examples.greetings.client.Batchfinders) Sets(org.testng.collections.Sets) StringMap(com.linkedin.data.template.StringMap) Greetings(com.linkedin.restli.examples.greetings.client.Greetings) TransferOwnershipRequest(com.linkedin.restli.examples.groups.api.TransferOwnershipRequest) GreetingsFluentClient(com.linkedin.restli.examples.greetings.client.GreetingsFluentClient) BooleanArray(com.linkedin.data.template.BooleanArray) Test(org.testng.annotations.Test)

Example 17 with StringMap

use of com.linkedin.data.template.StringMap in project rest.li by linkedin.

the class IndividualResponseConversionTask method toIndividualResponse.

private static IndividualResponse toIndividualResponse(String id, RestResponse restResponse) throws MimeTypeParseException, IOException {
    IndividualResponse individualResponse = new IndividualResponse();
    individualResponse.setStatus(restResponse.getStatus());
    individualResponse.setHeaders(new StringMap(restResponse.getHeaders()));
    ByteString entity = restResponse.getEntity();
    if (!entity.isEmpty()) {
        // TODO Avoid converting bytes to datamap here. Individual response should have only the bytes.
        individualResponse.setBody(new IndividualBody(DataMapConverter.bytesToDataMap(restResponse.getHeaders(), entity)));
    }
    return individualResponse;
}
Also used : StringMap(com.linkedin.data.template.StringMap) IndividualBody(com.linkedin.restli.common.multiplexer.IndividualBody) ByteString(com.linkedin.data.ByteString) IndividualResponse(com.linkedin.restli.common.multiplexer.IndividualResponse)

Example 18 with StringMap

use of com.linkedin.data.template.StringMap in project rest.li by linkedin.

the class TwitterAccountsResource method closeAccounts.

@Action(name = "closeAccounts")
public StringMap closeAccounts(@ActionParam("emailAddresses") StringArray emailAddresses, @ActionParam("someFlag") boolean someFlag, @ActionParam("options") @Optional StringMap options) {
    StringMap res = new StringMap();
    res.put("numClosed", "5");
    res.put("resultCode", "11");
    return new StringMap(res);
}
Also used : StringMap(com.linkedin.data.template.StringMap) Action(com.linkedin.restli.server.annotations.Action)

Example 19 with StringMap

use of com.linkedin.data.template.StringMap in project rest.li by linkedin.

the class MapGeneratorTest method testWithPrimitivesMap.

@Test
public void testWithPrimitivesMap() throws Throwable {
    String json = load("WithPrimitivesMap.json");
    WithPrimitivesMap original = new WithPrimitivesMap();
    IntegerMap ints = new IntegerMap();
    ints.put("a", 1);
    ints.put("b", 2);
    ints.put("c", 3);
    original.setInts(ints);
    LongMap longs = new LongMap();
    longs.put("a", 10L);
    longs.put("b", 20L);
    longs.put("c", 30L);
    original.setLongs(longs);
    FloatMap floats = new FloatMap();
    floats.put("a", 1.1f);
    floats.put("b", 2.2f);
    floats.put("c", 3.3f);
    original.setFloats(floats);
    DoubleMap doubles = new DoubleMap();
    doubles.put("a", 11.1d);
    doubles.put("b", 22.2d);
    doubles.put("c", 33.3d);
    original.setDoubles(doubles);
    BooleanMap booleans = new BooleanMap();
    booleans.put("a", true);
    booleans.put("b", false);
    booleans.put("c", true);
    original.setBooleans(booleans);
    StringMap strings = new StringMap();
    strings.put("a", "string1");
    strings.put("b", "string2");
    strings.put("c", "string3");
    original.setStrings(strings);
    BytesMap bytes = new BytesMap();
    bytes.put("a", SchemaFixtures.bytes1);
    bytes.put("b", SchemaFixtures.bytes2);
    bytes.put("c", SchemaFixtures.bytes3);
    original.setBytes(bytes);
    assertJson(original, json);
    WithPrimitivesMap roundTripped = new WithPrimitivesMap(roundTrip(original.data()));
    assertJson(roundTripped, json);
}
Also used : IntegerMap(com.linkedin.data.template.IntegerMap) LongMap(com.linkedin.data.template.LongMap) StringMap(com.linkedin.data.template.StringMap) BooleanMap(com.linkedin.data.template.BooleanMap) WithPrimitivesMap(com.linkedin.pegasus.generator.test.idl.maps.WithPrimitivesMap) BytesMap(com.linkedin.data.template.BytesMap) FloatMap(com.linkedin.data.template.FloatMap) DoubleMap(com.linkedin.data.template.DoubleMap) Test(org.testng.annotations.Test)

Example 20 with StringMap

use of com.linkedin.data.template.StringMap in project rest.li by linkedin.

the class TestGreetingsClient method testRecordActionVoidReturn.

@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testRecordActionVoidReturn(RootBuilderWrapper<Long, Greeting> builders) throws RemoteInvocationException {
    Request<Void> requestVoid = builders.<Void>action("AnotherAction").setActionParam("bitfield", new BooleanArray()).setActionParam("request", new TransferOwnershipRequest()).setActionParam("someString", "").setActionParam("stringMap", new StringMap()).build();
    ResponseFuture<Void> responseFutureVoid = getClient().sendRequest(requestVoid);
    Assert.assertEquals(responseFutureVoid.getResponse().getStatus(), 200);
    Assert.assertNull(responseFutureVoid.getResponse().getEntity());
}
Also used : StringMap(com.linkedin.data.template.StringMap) TransferOwnershipRequest(com.linkedin.restli.examples.groups.api.TransferOwnershipRequest) BooleanArray(com.linkedin.data.template.BooleanArray) Test(org.testng.annotations.Test)

Aggregations

StringMap (com.linkedin.data.template.StringMap)47 Test (org.testng.annotations.Test)26 RestLiResponseException (com.linkedin.restli.client.RestLiResponseException)9 FlowConfig (org.apache.gobblin.service.FlowConfig)9 FlowId (org.apache.gobblin.service.FlowId)9 Schedule (org.apache.gobblin.service.Schedule)9 Map (java.util.Map)8 IndividualRequest (com.linkedin.restli.common.multiplexer.IndividualRequest)6 IndividualRequestMap (com.linkedin.restli.common.multiplexer.IndividualRequestMap)5 TaskExecutionInfo (org.apache.gobblin.rest.TaskExecutionInfo)5 ByteString (com.linkedin.data.ByteString)4 DataMap (com.linkedin.data.DataMap)4 Meter (com.codahale.metrics.Meter)3 RestRequest (com.linkedin.r2.message.rest.RestRequest)3 RoutingResult (com.linkedin.restli.internal.server.RoutingResult)3 PreparedStatement (java.sql.PreparedStatement)3 AbstractMap (java.util.AbstractMap)3 JobExecutionInfo (org.apache.gobblin.rest.JobExecutionInfo)3 Metric (org.apache.gobblin.rest.Metric)3 MetricArray (org.apache.gobblin.rest.MetricArray)3