Package org.apache.stanbol.enhancer.servicesapi.helper

Examples of org.apache.stanbol.enhancer.servicesapi.helper.ContentItemImpl


    private static final UriRef ciUri = new UriRef("http://example.org/");
    private static final Blob blob = new InMemoryBlob("hello", null);

    @Test(expected=IllegalArgumentException.class)
    public void missingUri(){
        new ContentItemImpl(null,blob,new SimpleMGraph()){};
    }
View Full Code Here


    public void missingUri(){
        new ContentItemImpl(null,blob,new SimpleMGraph()){};
    }
    @Test(expected=IllegalArgumentException.class)
    public void missingBlob(){
        new ContentItemImpl(ciUri,null,new SimpleMGraph()){};
    }
View Full Code Here

    public void missingBlob(){
        new ContentItemImpl(ciUri,null,new SimpleMGraph()){};
    }
    @Test(expected=IllegalArgumentException.class)
    public void missingMetadata(){
        new ContentItemImpl(ciUri,blob,null){};
    }
View Full Code Here

        new ContentItemImpl(ciUri,blob,null){};
    }
   
  @Test
  public void addingAndRetrieving() {
    ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
    UriRef partUri = new UriRef("http://foo/");
    Date someObject = new Date();
    ci.addPart(partUri, someObject);
    ci.getMetadata().add(new TripleImpl(ciUri, new UriRef("http://example.org/ontology#hasPart"), partUri));
        ci.getMetadata().add(new TripleImpl(partUri, new UriRef("http://example.org/ontology#isPartOf"),ciUri));
    Assert.assertEquals(someObject, ci.getPart(partUri, Date.class));
    Assert.assertEquals(someObject, ci.getPart(1, Date.class));
    Assert.assertEquals(partUri, ci.getPartUri(1));
    Assert.assertEquals(new UriRef(ciUri.getUnicodeString()+"_main"), ci.getPartUri(0));
    try {
        ci.getPart(2, Object.class);
        Assert.assertTrue("Requesting non existance part MUST throw an NoSuchPartException", false);
    } catch (NoSuchPartException e) {/* expected*/}
        try {
            ci.getPart(new UriRef("http://foo/nonexisting"), Object.class);
            Assert.assertTrue("Requesting non existance part MUST throw an NoSuchPartException", false);
        } catch (NoSuchPartException e) {/* expected*/}
        try {
            ci.getPartUri(2);
            Assert.assertTrue("Requesting non existance part MUST throw an NoSuchPartException", false);
        } catch (NoSuchPartException e) {/* expected*/}
    //finally log the toString
    log.info("toString: {}",ci);
  }
View Full Code Here

    //finally log the toString
    log.info("toString: {}",ci);
  }
  @Test(expected=IllegalArgumentException.class)
  public void addPartWithoutUri(){
      ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
      ci.addPart(null, new Date());
  }
View Full Code Here

      ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
      ci.addPart(null, new Date());
  }
    @Test(expected=IllegalArgumentException.class)
    public void addPartWithoutPartContent(){
        ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
        ci.addPart(new UriRef("http://foo/"), null);
    }
View Full Code Here

     * The ContentItem MUST NOT allow to replace the main content part (the
     * Blob stored at index 0)
     */
    @Test(expected=IllegalArgumentException.class)
    public void replaceMainPart(){
        ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
        UriRef mainPart = ci.getPartUri(0);
        ci.addPart(mainPart, new Date());
    }
View Full Code Here

        UriRef mainPart = ci.getPartUri(0);
        ci.addPart(mainPart, new Date());
    }
    @Test(expected=IllegalArgumentException.class)
    public void removeNullPart() {
        ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
        ci.removePart(null);
    }
View Full Code Here

        ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
        ci.removePart(null);
    }
    @Test(expected=IllegalArgumentException.class)
    public void removeNegaitveIndexPart() {
        ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
        ci.removePart(-1);
    }
View Full Code Here

        ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
        ci.removePart(-1);
    }
    @Test(expected=IllegalStateException.class)
    public void removeMainContentPartByUri() {
        ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
        ci.removePart(ci.getPartUri(0));
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.enhancer.servicesapi.helper.ContentItemImpl

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.