Package io.teknek.intravert.model

Examples of io.teknek.intravert.model.Request


  @Test
  public void aTest(){
    IntravertService service = new DefaultIntravertService();
    String keyspaceName = "bla";
    {
      Request request = new Request();
      request.getOperations().add(new Operation().withId("1").withType(ActionFactory.CREATE_SESSION));
      request.getOperations()
              .add(new Operation()
                      .withId("2")
                      .withType(ActionFactory.SET_KEYSPACE)
                      .withArguments(
                              new ImmutableMap.Builder<String, Object>().put("name", keyspaceName).build()));
      Response response = service.doRequest(request);
      TestUtils.assertResponseDidNotFail(response);
      List<Map> results = (List<Map>) response.getResults().get("1");
      Assert.assertNotNull(results.get(0).get(Constants.SESSION_ID));
    }
    {
      Request other = new Request();
      other.getOperations().add(
              new Operation()
                      .withId("1")
                      .withType(ActionFactory.LOAD_SESSION)
                      .withArguments(
                              new ImmutableMap.Builder<String, Object>().put(Constants.SESSION_ID,
                                      0L).build()));
      other.getOperations().add(new Operation().withId("2").withType(ActionFactory.GET_KEYSPACE));
      Response second = service.doRequest(other);
      TestUtils.assertResponseDidNotFail(second);
      List<Map> results = (List<Map>) second.getResults().get("2");
      Assert.assertEquals(keyspaceName, results.get(0).get("keyspace"));
    }
View Full Code Here


public class CreateKeyspaceTest extends BaseIntravertTest {

  @Test
  public void createKeyspace() throws JsonGenerationException, JsonMappingException, IllegalStateException, UnsupportedEncodingException, IOException, RuntimeException{
    Request request = new Request();
    request.getOperations().add(new Operation().withId("1").withType(ActionFactory.CREATE_SESSION));
    request.getOperations()
            .add(new Operation()
                     .withId("2")
                    .withType(ActionFactory.SET_KEYSPACE)
                    .withArguments(
                            new ImmutableMap.Builder<String, Object>().put("name", "bla").build()));
View Full Code Here

public class CreateFilterTest extends BaseIntravertTest {

  @Test
  public void createApplicationFilter() throws JsonGenerationException, JsonMappingException, IllegalStateException, UnsupportedEncodingException, IOException, RuntimeException{
    Request request = new Request();
    Map<String,Object> filterDef = new HashMap<String,Object>();
    filterDef.put("spec", NitDesc.NitSpec.GROOVY_CLOSURE.toString());
    filterDef.put("name", "under21");
    filterDef.put("scope", "application");
    filterDef.put("script", "{ row -> if (row['value'].toInteger() > 21) return row else return null }");
    request.getOperations().add(new Operation()
    .withId("1").withType(ActionFactory.CREATE_FILTER).withArguments(filterDef));
    Client cl = new Client();
    Response response = cl.post("http://127.0.0.1:7654", request);
    List<Map> results = (List<Map>) response.getResults().get("1");
    Assert.assertEquals(new ImmutableMap.Builder<String, Object>().put("result", "ok").build(), results.get(0));
View Full Code Here

public class SerializeTest {

  @Ignore
  public void test() throws JsonGenerationException, JsonMappingException, IOException{
    Request request = new Request();
    Map<String,Object> filterDef = new HashMap<String,Object>();
    filterDef.put("string", "under21");
    filterDef.put("bytes", new Type("Blob", "application".getBytes()));
    filterDef.put("abtype", new Type(5L));
    filterDef.put("int", 5);
    filterDef.put("long", new Type("Long", 5L));
    filterDef.put("comp", new Type("Composite(Long,String)", Arrays.asList(5l, "waa")));
    filterDef.put("comp", new Type("CompositeSep(Long,String)", Arrays.asList(5l, 0, "waa", 0)));
    request.getOperations().add(new Operation()
    .withId("1").withType(ActionFactory.CREATE_FILTER).withArguments(filterDef));
    ObjectMapper om = new ObjectMapper();
    Assert.assertEquals("", om.writeValueAsString(request));
   
    //Client cl = new Client();
View Full Code Here

    File input = new File(testDir, "input.json");
    File output = new File(testDir, "output.json");
    Client c = new Client();
    ObjectMapper om  = new ObjectMapper();
    om.configure(Feature.INDENT_OUTPUT, true);
    Request r = om.readValue(input, Request.class);
    Response resp = c.post("http://localhost:7654", r);
    Assert.assertEquals(new String(Files.readAllBytes(output.toPath())).trim(), om.writeValueAsString(resp).trim());
  }
View Full Code Here

public class UpsertTest extends BaseIntravertTest {

  @Test
  public void createApplicationFilter() throws JsonGenerationException, JsonMappingException, IllegalStateException, UnsupportedEncodingException, IOException, RuntimeException{
    Request request = new Request();
    request.getOperations().add(new Operation().withId("0").withType(ActionFactory.CREATE_KEYSPACE).withArguments(
            new ImmutableMap.Builder<String, Object>()
            .put("name", "example")
            .put("replication", 1)
            .put("ignoreIfNotExists", true).build()));
   
    request.getOperations().add(new Operation().withId("1").withType(ActionFactory.CREATE_COLUMN_FAMILY).withArguments(
            new ImmutableMap.Builder<String, Object>()
            .put("keyspace", "example")
            .put("columnFamily", "upsert")
            .put("ignoreIfNotExists", true).build()));
    request.getOperations().add(new Operation()
    .withId("2").withType(ActionFactory.SET_KEYSPACE).withArguments(
            new ImmutableMap.Builder<String, Object>().put("name", "example").build()));
    request.getOperations().add(new Operation()
    .withId("3").withType(ActionFactory.UPSERT).withArguments(
            new ImmutableMap.Builder<String, Object>().put("rowkey", "ecapriolo")
            .put("column","firstname")
            .put("value","edward")
            .put("keyspace","example")
View Full Code Here

TOP

Related Classes of io.teknek.intravert.model.Request

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.