Package com.iqser.core.model

Examples of com.iqser.core.model.Content


        .getResourceAsStream(path));
    return jsonMapper.toJavaList(postJsonString, clazz);
  }

  private Content createDummyContentFromUrl(String contentUrl) {
    Content content = new Content();
    content.setProvider(providerID);
    content.setContentUrl(contentUrl);

    return content;
  }
View Full Code Here


 
  protected void setUp() throws Exception {
   
    securityFilter = new FacebookDefaultSecurityFilter();
   
    content = new Content();
     
  }
View Full Code Here

    assertEquals(true, isAllowed);
  }

  public void testCanExecuteDeleteAction() throws IQserSecurityException{

    Content content;
    String action;
    boolean isAllowed;
   
    //attribute is present
    String[] attribuetNames = new String[]{"from_id","owner_id"};
    for (String name : attribuetNames) {
      content = new Content();
      content.addAttribute(new Attribute(name, "100", Attribute.ATTRIBUTE_TYPE_TEXT));       
      action = FacebookContentProvider.ACTION_DELETE;
      isAllowed = securityFilter.canExecuteAction(user, password, action, content);   
      assertEquals(true, isAllowed);     
    }
       
    //attribute is present , wrong value
    content = new Content();
    content.addAttribute(new Attribute("from_id", "123", Attribute.ATTRIBUTE_TYPE_TEXT));       
    action = FacebookContentProvider.ACTION_DELETE;
    isAllowed = securityFilter.canExecuteAction(user, password, action, content);   
    assertEquals(false, isAllowed);
       
    //no attributes
    content = new Content();     
    action = FacebookContentProvider.ACTION_DELETE;
    isAllowed = securityFilter.canExecuteAction(user, password, action, content);
    assertEquals(false, isAllowed);

  }
View Full Code Here

    String POST_FBID = "122788341354";

    // create facebook post
    String contentUrl = URLUtils.makeContentURL(POST_FBID, "post");
    Content content = createDummyContentFromUrl(contentUrl);
    content.addAttribute(new Attribute("from_id", "friendId",
        Attribute.ATTRIBUTE_TYPE_TEXT));
    content.addAttribute(new Attribute("name", "post name",
        Attribute.ATTRIBUTE_TYPE_TEXT));
    content.addAttribute(new Attribute("message", "post message",
        Attribute.ATTRIBUTE_TYPE_TEXT));

    // check if documents exists in object graph
    assertTrue(repo.getContentByProvider(providerID, true).size() == 0);
View Full Code Here

        .andReturn(expectedPost);

    // register behavior
    EasyMock.replay(mockFbClient);

    Content content = builder.getContent(contentUrl);

    // verify
    EasyMock.verify();

    // assertions
    assertNotNull(content);
    assertNotNull(content.getModificationDate());
    assertEquals(ContentTypeEnum.POST.name(), content.getType());
    assertEquals(providerID, content.getProvider());

    assertTrue(content.getAttributes().size() > 0);

    // test all attributes
    assertEquals("Facebook Platform",
        content.getAttributeByName("from_name").getValue());
    assertEquals("19292868552", content.getAttributeByName("from_id")
        .getValue());

    assertNotNull(content.getAttributeByName("comments"));

  }
View Full Code Here

        .getResourceAsStream(path));
    return jsonMapper.toJavaList(postJsonString, clazz);
  }

  private Content createDummyContentFromUrl(String contentUrl) {
    Content content = new Content();
    content.setProvider(providerID);
    content.setContentUrl(contentUrl);

    return content;
  }
View Full Code Here

        .andReturn(expectedComment);

    // register behavior
    EasyMock.replay(mockFbClient);

    Content content = builder.getContent(contentUrl);

    // verify
    EasyMock.verify();

    // assertions
    assertNotNull(content);
    assertNotNull(content.getModificationDate());
    assertEquals(ContentTypeEnum.COMMENT.name(), content.getType());
    assertEquals(providerID, content.getProvider());

    assertTrue(content.getAttributes().size() > 0);

    // test all attributes
    assertEquals("19292868552_118464504835613_388624", content
        .getAttributeByName("id").getValue());
    assertEquals("19292868552_118464504835613",
        content.getAttributeByName("parent_id").getValue());
    assertEquals("1458135488", content.getAttributeByName("from_id")
        .getValue());
    assertEquals("Facebook Platform",
        content.getAttributeByName("from_name").getValue());
    assertEquals("1", content.getAttributeByName("likes_count").getValue());
    assertNotNull(content.getAttributeByName("created_time").getValue());
  }
View Full Code Here

    logger.debug("addContent() called for content " + c.getContentUrl());
   
    Iterator iter = cl.iterator();
   
    while (iter.hasNext()) {
      Content oldc = (Content)iter.next();
     
      if (oldc.getContentUrl().equals(c.getContentUrl()) &&
          oldc.getProvider().equals(c.getProvider())) {
        throw new IQserTechnicalException(
            "Content object already exists", IQserTechnicalException.SEVERITY_ERROR);
      }
    }
     
View Full Code Here

  public boolean contains(String url, String provider)
      throws IQserTechnicalException {
    logger.debug("contains() called for " + url + " and " + provider);
   
    Iterator iter = cl.iterator();
    Content c = null;
   
    while (iter.hasNext()) {
      c = (Content)iter.next();
      if (c.getContentUrl().equals(url) && c.getProvider().equals(provider))
          return true;
    }
   
    return false;
  }
View Full Code Here

  public void deleteContent(Content c) throws IQserTechnicalException {
    logger.debug("deleteContent() called for " + c.getContentUrl());
   
    Iterator iter = cl.iterator();
    boolean removed = false;
    Content oldc = null;
   
    while (iter.hasNext()) {
      oldc = (Content)iter.next();
     
      if (oldc.getContentUrl().equals(c.getContentUrl()) &&
          oldc.getProvider().equals(c.getProvider())) {
        removed = true;
        break;
      }
    }
   
View Full Code Here

TOP

Related Classes of com.iqser.core.model.Content

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.