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

Examples of org.apache.stanbol.enhancer.servicesapi.helper.ContentItemImpl.addPart()


  @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));
View Full Code Here


    log.info("toString: {}",ci);
  }
  @Test(expected=IllegalArgumentException.class)
  public void addPartWithoutUri(){
      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

      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);
    }
    /**
     * The ContentItem MUST NOT allow to replace the main content part (the
     * Blob stored at index 0)
     */
 
View Full Code Here

     */
    @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());
    }
    @Test(expected=IllegalArgumentException.class)
    public void removeNullPart() {
        ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
        ci.removePart(null);
View Full Code Here

    }
    @Test
    public void removeRemoveByUri() {
        ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
        UriRef uri = new UriRef("urn:content.part:remove.test");
        ci.addPart(uri, new Date());
        try {
            ci.getPart(uri, Date.class);
        }catch (NoSuchPartException e) {
            Assert.assertFalse("The part with the uri "+uri+" was not added correctly",
                true);
View Full Code Here

    }
    @Test
    public void removeRemoveByIndex() {
        ContentItem ci = new ContentItemImpl(ciUri,blob,new SimpleMGraph()){};
        UriRef uri = new UriRef("urn:content.part:remove.test");
        ci.addPart(uri, new Date());
        int index = -1;
        try {
            for(int i=0; index < 0; i++){
                UriRef partUri = ci.getPartUri(i);
                if(partUri.equals(uri)){
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.