Package io.teknek.intravert.model

Examples of io.teknek.intravert.model.Operation


  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()));
    Client cl = new Client();
View Full Code Here

    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

    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

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

 
  @Override
  public void process(Request request, Response response, RequestContext requestContext,
          ApplicationContext application) {
    for (int i = 0; i < request.getOperations().size(); i++) {
      Operation operation = null;
      try {
        operation = request.getOperations().get(i);
        Action action = actionFatory.findAction(operation.getType());
        action.doAction(operation, response, requestContext, application);
      } catch (RuntimeException ex) {
        response.setExceptionId(operation.getId());
        response.setExceptionMessage(ex.getMessage());
        ex.printStackTrace();
        break;
      }
    }
View Full Code Here

TOP

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

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.