Package com.ikanow.infinit.e.data_model.store.social.sharing

Examples of com.ikanow.infinit.e.data_model.store.social.sharing.SharePojo


  public void testGet() throws IOException
  {
    //2 things to test, get s specific share and search shares
   
    //first inject a share
    SharePojo share = createJSONShare();
   
    //assert the share we get has the same id as the one we created
    assertTrue(getShare(share.get_id().toString()).get_id().equals(share.get_id()));
   
    //assert our search brings up the same share
    List<SharePojo> shares = searchShares(share.getType());
    boolean found = false;
    for ( SharePojo sp : shares )
    {
      if ( sp.get_id().equals(share.get_id()))
      {
        found = true;
        break;
      }
    }
    deleteShare(share.get_id().toString());   
   
    assertTrue(found);
   
   
  }
View Full Code Here


  @Test
  public void testPostRepresentation() throws IOException
  {
    //test post json
    SharePojo share_json = createJSONShare();
    assertTrue( share_json != null );
   
    //test post ref
    SharePojo share_ref = createRefShare();
    assertTrue( share_ref != null );
   
    //test post bin
    SharePojo share_bin = createBinShare();
    assertTrue( share_bin != null );
   
    //cleanup
    deleteShare(share_json.get_id().toString());
    deleteShare(share_ref.get_id().toString());
    deleteShare(share_bin.get_id().toString());
  }
View Full Code Here

  }

  @Test
  public void testPutRepresentation() throws IOException
  {
    SharePojo share_json = createJSONShare();
   
    //test update metadata
    SharePojo updated_pojo = new SharePojo();
    updated_pojo.set_id(share_json.get_id());
    updated_pojo.setTitle("new title");
    SharePojo returned_pojo = updateShare(updated_pojo);   
    assertTrue(returned_pojo.getTitle().equals(updated_pojo.getTitle()));   
   
    //test update comms
    updated_pojo = new SharePojo();
    updated_pojo.set_id(share_json.get_id());
    List<ShareCommunityPojo> communities = new ArrayList<SharePojo.ShareCommunityPojo>();
    ShareCommunityPojo scp = new ShareCommunityPojo();
    scp.set_id(new ObjectId("53ff3851e4b0db2c2b27c82e")); //test api community
    communities.add(scp);
    updated_pojo.setCommunities(communities);
    returned_pojo = updateShare(updated_pojo);
    assertTrue(returned_pojo.getCommunities().get(0).get_id().equals(new ObjectId("53ff3851e4b0db2c2b27c82e")));
   
    //test update json/ref/bin
    updated_pojo = new SharePojo();
    updated_pojo.set_id(share_json.get_id());
    updated_pojo.setShare("{\"test\":\"update\"}");
    returned_pojo = updateShare(updated_pojo);
    assertTrue(updated_pojo.getShare().length() != share_json.getShare().length());
    deleteShare(returned_pojo.get_id().toString());
  }
View Full Code Here

  }
 
  @Test
  public void testDeleteRepresentation() throws IOException
  {
    SharePojo share = createJSONShare();
    assertTrue(getShare(share.get_id().toString()).get_id().equals(share.get_id()));
    deleteShare(share.get_id().toString());
    SharePojo non_exist = getShare(share.get_id().toString());
    assertNull(non_exist);
  }
View Full Code Here

    String share_string = updated_share.toDb().toString();
   
    Representation entity = new StringRepresentation(share_string);
    Representation rep = shareV2Interface.put(entity);
    ResponsePojo rp = ResponsePojo.fromApi( rep.getText(), null, ResponsePojo.class);
    SharePojo share = ApiManager.mapFromApi((JsonElement)rp.getData(), SharePojo.class, new SharePojoApiMap(null));
    return share;
 
View Full Code Here

    shareV2Interface.setRequest(request)
    shareV2Interface.setResponse(new Response(request));
    shareV2Interface.doInit();
    Representation rep = shareV2Interface.get();
    ResponsePojo rp = ResponsePojo.fromApi( rep.getText(), null, ResponsePojo.class);
    SharePojo share = ApiManager.mapFromApi((JsonObject)rp.getData(), SharePojo.class, new SharePojoApiMap(null));
    return share;
  }
View Full Code Here

    }
    catch (Exception ex)
    {
      //might be a single item
      shares = new ArrayList<SharePojo>();
      SharePojo share = ApiManager.mapFromApi((JsonObject)rp.getData(), SharePojo.class, new SharePojoApiMap(null));
      shares.add(share);
    }
    return shares;
  }
View Full Code Here

    shareV2Interface.doInit();
   
    Representation entity = new StringRepresentation("{  \"title\":\"test\",\"description\":\"test desc\",\"type\":\"test1\",\"communities\":[{\"_id\":\"4c927585d591d31d7b37097a\"}],\"share\":\"{}\"}");
    Representation rep = shareV2Interface.post(entity);
    ResponsePojo rp = ResponsePojo.fromApi( rep.getText(), null, ResponsePojo.class);
    SharePojo share = ApiManager.mapFromApi((JsonElement)rp.getData(), SharePojo.class, new SharePojoApiMap(null));
    return share;
  }
View Full Code Here

    Request request = getRequestWithCookie(Method.POST, "");   
    shareV2Interface.setRequest(request)
    shareV2Interface.setResponse(new Response(request));
    shareV2Interface.doInit();
   
    SharePojo share_ref = new SharePojo();
    share_ref.setTitle("test_ref");
    share_ref.setDescription("123");
    share_ref.setType("test1");
    List<ShareCommunityPojo> communities = new ArrayList<SharePojo.ShareCommunityPojo>();
    ShareCommunityPojo scp = new ShareCommunityPojo();
    scp.set_id(new ObjectId("4c927585d591d31d7b37097a")); //this is inf system i think
    communities.add(scp);
    share_ref.setCommunities(communities);
    DocumentLocationPojo dlp = new DocumentLocationPojo();
    dlp.setDatabase("doc_metadata");
    dlp.setCollection("metadata");
    dlp.set_id(new ObjectId("53fe2c83e4b060b5b2a6e779")); //this needs to be a valid doc
    share_ref.setDocumentLocation(dlp);
    String share_string = share_ref.toDb().toString();
   
    Representation entity = new StringRepresentation(share_string);
    Representation rep = shareV2Interface.post(entity);
    ResponsePojo rp = ResponsePojo.fromApi( rep.getText(), null, ResponsePojo.class);
    SharePojo share = ApiManager.mapFromApi((JsonElement)rp.getData(), SharePojo.class, new SharePojoApiMap(null));
    return share;
  }
View Full Code Here

    Request request = getRequestWithCookie(Method.POST, "");   
    shareV2Interface.setRequest(request)
    shareV2Interface.setResponse(new Response(request));
    shareV2Interface.doInit();
   
    SharePojo share_bin = new SharePojo();
    share_bin.setTitle("test_bin");
    share_bin.setDescription("123");
    share_bin.setType("test1");
    List<ShareCommunityPojo> communities = new ArrayList<SharePojo.ShareCommunityPojo>();
    ShareCommunityPojo scp = new ShareCommunityPojo();
    scp.set_id(new ObjectId("4c927585d591d31d7b37097a")); //this is inf system i think
    communities.add(scp);
    share_bin.setCommunities(communities);
    String binary_data = "secret binary data";
    share_bin.setBinaryData(binary_data.getBytes());
    String share_string = share_bin.toDb().toString();
   
    Representation entity = new StringRepresentation(share_string);
    Representation rep = shareV2Interface.post(entity);
    ResponsePojo rp = ResponsePojo.fromApi( rep.getText(), null, ResponsePojo.class);
    SharePojo share = ApiManager.mapFromApi((JsonElement)rp.getData(), SharePojo.class, new SharePojoApiMap(null));
    return share;
  }
View Full Code Here

TOP

Related Classes of com.ikanow.infinit.e.data_model.store.social.sharing.SharePojo

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.