Search in sources :

Example 11 with ParSeqRestliClientConfigBuilder

use of com.linkedin.restli.client.ParSeqRestliClientConfigBuilder in project parseq by linkedin.

the class TestRequestConfigProvider method testPrioritiesWithInboundFinderAndOutboundMatch.

@Test
public void testPrioritiesWithInboundFinderAndOutboundMatch() throws RequestConfigKeyParsingException {
    ParSeqRestliClientConfigBuilder configBuilder = new ParSeqRestliClientConfigBuilder();
    configBuilder.addTimeoutMs("*.*/*.GET", 1000L);
    configBuilder.addTimeoutMs("x.GET/*.GET", 1000L);
    configBuilder.addTimeoutMs("y.GET/x1.GET", 1000L);
    configBuilder.addTimeoutMs("y.GET/x2.GET", 1000L);
    configBuilder.addTimeoutMs("*.GET/x.GET", 1000L);
    configBuilder.addTimeoutMs("*.GET/x2.GET", 1000L);
    configBuilder.addTimeoutMs("*.GET/greetings.GET", 1000L);
    configBuilder.addTimeoutMs("greetings.GET/*.GET", 1000L);
    configBuilder.addTimeoutMs("greetings.GET/greetings.GET", 100L);
    configBuilder.addTimeoutMs("*.*/greetings.DELETE", 1000L);
    configBuilder.addTimeoutMs("greetings.*/greetings.DELETE", 1000L);
    configBuilder.addTimeoutMs("*.GET/greetings.DELETE", 1000L);
    configBuilder.addTimeoutMs("greetings.GET/greetings.DELETE", 500L);
    configBuilder.addTimeoutMs("greetings.FINDER-*/greetings.GET", 500L);
    configBuilder.addTimeoutMs("greetings.FINDER-*/greetings.DELETE", 500L);
    configBuilder.addTimeoutMs("greetings.FINDER-foobar/greetings.GET", 500L);
    configBuilder.addTimeoutMs("greetings.FINDER-foobar/greetings.DELETE", 500L);
    configBuilder.addTimeoutMs("greetings.FINDER-findAll/greetings.GET", 400L);
    configBuilder.addTimeoutMs("greetings.FINDER-findAll/greetings.DELETE", 300L);
    RequestConfigProvider provider = RequestConfigProvider.build(configBuilder.build(), requestContextFinder("greetings", "FINDER", Optional.of("findAll"), Optional.empty()));
    RequestConfig rc = provider.apply(new GreetingsBuilders().get().id(0L).build());
    assertNotNull(rc);
    assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(400L));
    assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
    assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
    rc = provider.apply(new GreetingsBuilders().delete().id(0L).build());
    assertNotNull(rc);
    assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(300L));
    assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
    assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
}
Also used : ParSeqRestliClientConfigBuilder(com.linkedin.restli.client.ParSeqRestliClientConfigBuilder) GreetingsBuilders(com.linkedin.restli.examples.greetings.client.GreetingsBuilders) Test(org.testng.annotations.Test)

Example 12 with ParSeqRestliClientConfigBuilder

use of com.linkedin.restli.client.ParSeqRestliClientConfigBuilder in project parseq by linkedin.

the class TestRequestConfigProvider method testPrioritiesWithInboundAndOutboundMatchSubresource.

@Test
public void testPrioritiesWithInboundAndOutboundMatchSubresource() throws RequestConfigKeyParsingException {
    ParSeqRestliClientConfigBuilder configBuilder = new ParSeqRestliClientConfigBuilder();
    configBuilder.addTimeoutMs("*.*/*.GET", 1000L);
    configBuilder.addTimeoutMs("x.GET/*.GET", 1001L);
    configBuilder.addTimeoutMs("y.GET/x1.GET", 1002L);
    configBuilder.addTimeoutMs("y.GET/x2.GET", 1003L);
    configBuilder.addTimeoutMs("*.GET/x.GET", 1004L);
    configBuilder.addTimeoutMs("*.GET/x2.GET", 1005L);
    configBuilder.addTimeoutMs("*.GET/greetings.GET", 1006L);
    configBuilder.addTimeoutMs("greetings.GET/*.GET", 1007L);
    configBuilder.addTimeoutMs("greetings:associationsSub.GET/greetings.GET", 1008L);
    RequestConfigProvider provider = RequestConfigProvider.build(configBuilder.build(), requestContextFinder("greetings", ResourceMethod.GET.toString().toUpperCase(), Optional.empty(), Optional.empty()));
    RequestConfig rc = provider.apply(new GreetingsBuilders().get().id(0L).build());
    assertNotNull(rc);
    assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(1006L));
    assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
    assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
}
Also used : ParSeqRestliClientConfigBuilder(com.linkedin.restli.client.ParSeqRestliClientConfigBuilder) GreetingsBuilders(com.linkedin.restli.examples.greetings.client.GreetingsBuilders) Test(org.testng.annotations.Test)

Example 13 with ParSeqRestliClientConfigBuilder

use of com.linkedin.restli.client.ParSeqRestliClientConfigBuilder in project parseq by linkedin.

the class TestRequestConfigProvider method testPrioritiesWithInboundAndOutboundMatch.

@Test
public void testPrioritiesWithInboundAndOutboundMatch() throws RequestConfigKeyParsingException {
    ParSeqRestliClientConfigBuilder configBuilder = new ParSeqRestliClientConfigBuilder();
    configBuilder.addTimeoutMs("*.*/*.GET", 1000L);
    configBuilder.addTimeoutMs("x.GET/*.GET", 1000L);
    configBuilder.addTimeoutMs("y.GET/x1.GET", 1000L);
    configBuilder.addTimeoutMs("y.GET/x2.GET", 1000L);
    configBuilder.addTimeoutMs("*.GET/x.GET", 1000L);
    configBuilder.addTimeoutMs("*.GET/x2.GET", 1000L);
    configBuilder.addTimeoutMs("*.GET/greetings.GET", 1000L);
    configBuilder.addTimeoutMs("greetings.GET/*.GET", 1000L);
    configBuilder.addTimeoutMs("greetings.GET/greetings.GET", 100L);
    configBuilder.addTimeoutMs("*.*/greetings.DELETE", 1000L);
    configBuilder.addTimeoutMs("greetings.*/greetings.DELETE", 1000L);
    configBuilder.addTimeoutMs("*.GET/greetings.DELETE", 1000L);
    configBuilder.addTimeoutMs("greetings.GET/greetings.DELETE", 500L);
    RequestConfigProvider provider = RequestConfigProvider.build(configBuilder.build(), requestContextFinder("greetings", ResourceMethod.GET.toString().toUpperCase(), Optional.empty(), Optional.empty()));
    RequestConfig rc = provider.apply(new GreetingsBuilders().get().id(0L).build());
    assertNotNull(rc);
    assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(100L));
    assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
    assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
    rc = provider.apply(new GreetingsBuilders().delete().id(0L).build());
    assertNotNull(rc);
    assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(500L));
    assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
    assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
}
Also used : ParSeqRestliClientConfigBuilder(com.linkedin.restli.client.ParSeqRestliClientConfigBuilder) GreetingsBuilders(com.linkedin.restli.examples.greetings.client.GreetingsBuilders) Test(org.testng.annotations.Test)

Example 14 with ParSeqRestliClientConfigBuilder

use of com.linkedin.restli.client.ParSeqRestliClientConfigBuilder in project parseq by linkedin.

the class TestRequestConfigProvider method testTimeoutForGetManyConfigs.

@Test
public void testTimeoutForGetManyConfigs() throws RequestConfigKeyParsingException {
    ParSeqRestliClientConfigBuilder configBuilder = new ParSeqRestliClientConfigBuilder();
    configBuilder.addTimeoutMs("*.*/*.GET", 1000L);
    configBuilder.addTimeoutMs("x.GET/*.GET", 1000L);
    configBuilder.addTimeoutMs("y.GET/x1.GET", 1000L);
    configBuilder.addTimeoutMs("y.GET/x2.GET", 1000L);
    configBuilder.addTimeoutMs("*.GET/x.GET", 1000L);
    configBuilder.addTimeoutMs("*.GET/x2.GET", 1000L);
    RequestConfigProvider provider = RequestConfigProvider.build(configBuilder.build(), () -> Optional.empty());
    RequestConfig rc = provider.apply(new GreetingsBuilders().get().id(0L).build());
    assertNotNull(rc);
    assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(1000L));
    assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
    assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
    rc = provider.apply(new GreetingsBuilders().delete().id(0L).build());
    assertNotNull(rc);
    assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(DEFAULT_TIMEOUT));
    assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
    assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
}
Also used : ParSeqRestliClientConfigBuilder(com.linkedin.restli.client.ParSeqRestliClientConfigBuilder) GreetingsBuilders(com.linkedin.restli.examples.greetings.client.GreetingsBuilders) Test(org.testng.annotations.Test)

Example 15 with ParSeqRestliClientConfigBuilder

use of com.linkedin.restli.client.ParSeqRestliClientConfigBuilder in project parseq by linkedin.

the class TestRequestConfigProvider method testPrioritiesOutboundNameSubResource.

@Test
public void testPrioritiesOutboundNameSubResource() throws RequestConfigKeyParsingException {
    ParSeqRestliClientConfigBuilder configBuilder = new ParSeqRestliClientConfigBuilder();
    configBuilder.addTimeoutMs("*.*/associations:foo.*", 1000L);
    configBuilder.addTimeoutMs("*.*/associations.*", 1001L);
    configBuilder.addTimeoutMs("*.*/associations:associationsSub.*", 1002L);
    RequestConfigProvider provider = RequestConfigProvider.build(configBuilder.build(), () -> Optional.empty());
    RequestConfig rc = provider.apply(new AssociationsSubBuilders().get().srcKey("a").destKey("b").id("x").build());
    assertNotNull(rc);
    assertEquals(rc.getTimeoutMs().getValue(), Long.valueOf(1002L));
    assertEquals(rc.isBatchingEnabled().getValue(), Boolean.valueOf(false));
    assertEquals(rc.getMaxBatchSize().getValue(), Integer.valueOf(1024));
}
Also used : ParSeqRestliClientConfigBuilder(com.linkedin.restli.client.ParSeqRestliClientConfigBuilder) AssociationsSubBuilders(com.linkedin.restli.examples.greetings.client.AssociationsSubBuilders) Test(org.testng.annotations.Test)

Aggregations

ParSeqRestliClientConfigBuilder (com.linkedin.restli.client.ParSeqRestliClientConfigBuilder)17 Test (org.testng.annotations.Test)14 GreetingsBuilders (com.linkedin.restli.examples.greetings.client.GreetingsBuilders)12 AssociationsSubBuilders (com.linkedin.restli.examples.greetings.client.AssociationsSubBuilders)5 ParSeqUnitTestHelper (com.linkedin.parseq.ParSeqUnitTestHelper)3 ParSeqRestliClientBuilder (com.linkedin.restli.client.ParSeqRestliClientBuilder)3 BeforeClass (org.testng.annotations.BeforeClass)3 RestLiValidationFilter (com.linkedin.restli.server.validation.RestLiValidationFilter)2 Task (com.linkedin.parseq.Task)1 BatchingSupport (com.linkedin.parseq.batching.BatchingSupport)1 Trace (com.linkedin.parseq.trace.Trace)1 ExecutionGroup (com.linkedin.restli.client.ExecutionGroup)1 ParSeqBasedCompletionStage (com.linkedin.restli.client.ParSeqBasedCompletionStage)1 ParSeqRestliClient (com.linkedin.restli.client.ParSeqRestliClient)1 ParSeqRestliClientConfig (com.linkedin.restli.client.ParSeqRestliClientConfig)1 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)1 GreetingsFluentClient (com.linkedin.restli.examples.greetings.client.GreetingsFluentClient)1 GroupsBuilders (com.linkedin.restli.examples.groups.client.GroupsBuilders)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1