Package gwtappcontainer.server.apps.content

Examples of gwtappcontainer.server.apps.content.ContentAPI


 
  @Test
  public void developerCanAddNewTag() {
    helper.loginAsDeveloper();
   
    ContentAPI api = new ContentAPI();
    String tag = "tag_" + UUID.randomUUID();
   
    User user = UserServiceFactory.getUserService().getCurrentUser();
    APIResponse resp = api.addNewTag(tag, user);
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    resp = api.getAllTags();
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    @SuppressWarnings("unchecked")
    List<String> tags = (List<String>) resp.object;
    assertTrue(tags.contains(tag.toUpperCase()));       
View Full Code Here


    addNewTag(tag);
     
    //assign this tag to user
    helper.loginAsPortalAdmin();
    User user = UserServiceFactory.getUserService().getCurrentUser();
    ContentAPI contentApi = new ContentAPI();
    APIResponse resp = contentApi.assignUserAsContentAdmin(email,
        tag, user);
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    //check if role exists
    AdminAPI adminApi = new AdminAPI();
View Full Code Here

    //first create the tag
    String tag = "tag_" + UUID.randomUUID();
    addNewTag(tag);
     
    //login as developer and assign this tag to user   
    ContentAPI contentApi = new ContentAPI();
   
    APIResponse response = contentApi.assignUserAsContentAdmin(email, tag,
        helper.loginAsDeveloper());
    assertTrue(response.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);   
  }
View Full Code Here

    addNewTag(tag);
   
    String email = "test@example.com";
    addNewUser(email);
   
    ContentAPI api = new ContentAPI();
   
    APIResponse resp = api.assignUserAsContentAdmin(email, tag,
        helper.loginAsPortalAdmin());
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    String content = "dummy content";
    User user = helper.loginAs(email);
    resp = api.setContent(content, tag, true, user);
   
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    //ensure content can be retrieved
    resp = api.getContent(tag, user);
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    ContentProp prop = (ContentProp) resp.object;
   
    assertTrue(prop.html.equals(content));
View Full Code Here

  @Test
  public void canSetContentIfPortalAdmin() {
    String tag = "tag_" + UUID.randomUUID();
    addNewTag(tag);
       
    ContentAPI api = new ContentAPI();
       
    String content = "dummy content";
    User user = helper.loginAsPortalAdmin();
    APIResponse resp = api.setContent(content, tag, false, user);
   
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    //ensure content can be retrieved
    resp = api.getContent(tag, user);
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    ContentProp prop = (ContentProp) resp.object;
   
    assertTrue(prop.html.equals(content));
View Full Code Here

  @Test
  public void canSetLargeContent() {
    String tag = "tag_" + UUID.randomUUID();
    addNewTag(tag);
       
    ContentAPI api = new ContentAPI();
   
    StringBuilder content = new StringBuilder();
    for (int i = 0; i < 255; i++) {
      content.append("1");
    }
           
    User user = helper.loginAsPortalAdmin();
    APIResponse resp = api.setContent(content.toString(),
        tag, true, helper.loginAsPortalAdmin());
   
    resp = api.setLargeContent(tag, true,
        content.toString(), content.toString(), content.toString(),
        null, null, "1111", null, null, null,
        helper.loginAsPortalAdmin());       
   
    //ensure content can be retrieved
    resp = api.getContent(tag, user);
   
    ContentProp prop = (ContentProp) resp.object;
    String expected = content.toString() + content.toString()
        + content.toString() + "1111";
    assertTrue(prop.html.equals(expected));
View Full Code Here

  @Test
  public void cannotSetContentIfNotContentAdminOrPortalAdmin() {
    String tag = "tag_" + UUID.randomUUID();
    addNewTag(tag);
       
    ContentAPI api = new ContentAPI();
       
    String content = "dummy content";
    User user = helper.loginAsPortalReadOnly();
       
    APIResponse resp = api.setContent(content, tag, false, user);
    assertTrue(resp.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);   
  }
View Full Code Here

  @Test
  public void canGetUnpublishedContentOnlyIfValidUser() {
    String tag = "tag_" + UUID.randomUUID();
    addNewTag(tag);
       
    ContentAPI api = new ContentAPI();
       
    String content = "dummy content";
    User user = helper.loginAsPortalAdmin();
    APIResponse resp = api.setContent(content, tag, false, user);
   
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    //ensure error when not logged in     
    resp = api.getContent(tag, null);
    assertTrue(resp.statusCode == Status.ERROR_LOGIN_REQUIRED);
       
    //ensure error when invalid user   
    String email = "test_" + UUID.randomUUID() + "@example.com";   
    resp = api.getContent(tag, helper.loginAs(email));
    assertTrue(resp.statusCode == Status.ERROR_INVALID_USER);   
   
    //ensure success if valid user
    resp = api.getContent(tag, helper.loginAsPortalUser());
    assertTrue(resp.statusCode == Status.SUCCESS);   
  }
View Full Code Here

  @Test
  public void anyoneCanGetPublishedContent() {
    String tag = "tag_" + UUID.randomUUID();
    addNewTag(tag);
       
    ContentAPI api = new ContentAPI();
       
    String content = "dummy content";
    User user = helper.loginAsPortalAdmin();
    APIResponse resp = api.setContent(content, tag, true, user);
   
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    //ensure content can be retrieved even without login
    resp = api.getContent(tag, null);
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    ContentProp prop = (ContentProp) resp.object;
   
    assertTrue(prop.html.equals(content));
View Full Code Here

 
  @Test
  public void getContentForInvalidTagGivesResourceNotFoundError() {
    String tag = "tag_" + UUID.randomUUID();
   
    ContentAPI api = new ContentAPI();
   
    APIResponse response = api.getContent(tag, helper.loginAsPortalAdmin());
    assertTrue(response.statusCode == Status.ERROR_RESOURCE_DOES_NOT_EXIST);   
  }
View Full Code Here

TOP

Related Classes of gwtappcontainer.server.apps.content.ContentAPI

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.