Examples of Yard


Examples of org.apache.stanbol.entityhub.servicesapi.yard.Yard

        assertFalse("Two Representation created with create() MUST NOT be equals", test.equals(test2));
    }

    @Test
    public void testCreateWithNull() throws YardException {
        Yard yard = getYard();
        Representation test = yard.create(null);
        assertNotNull("Parsing NULL to create(String) MUST create a valid Representation", test);
        representationIds.add(test.getId()); // add id to cleanup list
        Representation test2 = yard.create(null);
        assertNotNull("Parsing NULL to create(String) MUST create a valid Representation", test2);
        representationIds.add(test2.getId()); // add id to cleanup list
        assertNotSame(test, test2);
        assertFalse("Two Representation created with create(null) MUST NOT be equals", test.equals(test2));
    }
View Full Code Here

Examples of org.apache.stanbol.entityhub.servicesapi.yard.Yard

        getYard().create("");// throws an IllegalArgumentException
    }

    @Test(expected = IllegalArgumentException.class)
    public void testCreateWithExistingId() throws YardException {
        Yard yard = getYard();
        Representation test = create();
        assertNotNull(test);
        yard.create(test.getId()); // throws an IllegalArgumentException
    }
View Full Code Here

Examples of org.apache.stanbol.entityhub.servicesapi.yard.Yard

        // stored, but only that the store method works for representations
        // that are already in the Yard AND representations that are not yet
        // present within the yard
        String testId = "urn:yard.test.testStoreRepresentation:representation.id1";
        String testId2 = "urn:yard.test.testStoreRepresentation:representation.id2";
        Yard yard = getYard();
        Representation test = create(testId, false);
        Representation added = yard.store(test); // this adds the representation
        assertEquals(test, added);
        Representation test2 = create(testId2, true); // this creates and adds the representation
        // now test that the representation can also be updated
        added = yard.store(test2);
        assertEquals(test2, added);
    }
View Full Code Here

Examples of org.apache.stanbol.entityhub.servicesapi.yard.Yard

     * in case the yard is currently not available
     * @return the yard
     * @throws YardException in case the yard is not active
     */
    private Yard lookupYard() throws YardException {
        Yard yard = getYard();
        if(yard == null){
            throw new YardException("The Entityhub Yard (ID="+config.getEntityhubYardId()+") is not active! Please check the configuration!!");
        }
        return yard;
    }
View Full Code Here

Examples of org.apache.stanbol.entityhub.servicesapi.yard.Yard

    @Override
    public final Entity getEntity(String entityId) throws IllegalArgumentException,IllegalStateException, YardException {
        if(entityId == null || entityId.isEmpty()){
            throw new IllegalArgumentException("The parsed id MUST NOT be NULL nor empty!");
        }
        Yard entityhubYard = lookupYard();
        Entity entity = loadEntity(entityhubYard, entityId);
        if(entity == null){
            return null;
        } else if (ManagedEntity.canWrap(entity)){
            return entity;
View Full Code Here

Examples of org.apache.stanbol.entityhub.servicesapi.yard.Yard

    @Override
    public final Entity store(Representation representation) throws EntityhubException, IllegalArgumentException {
        if(representation == null){
            throw new IllegalArgumentException("The parsed Representation MUST NOT be NULL!");
        }
        Yard yard = lookupYard();
        //parse only the id of the representation, because we need the current
        //stored version of the entity!
        Entity entity = loadEntity(yard, representation.getId());
        //now we need to check if the parsed representation is the data or the
        //metadata of the Entity
View Full Code Here

Examples of org.apache.stanbol.entityhub.servicesapi.yard.Yard

        // that are already in the Yard AND representations that are not yet
        // present within the yard
        String testId = "urn:yard.test.testStoreRepresentations:representation.id1";
        String testId2 = "urn:yard.test.testStoreRepresentations:representation.id2";
        String field = "urn:the.field:used.for.this.Test";
        Yard yard = getYard();
        Representation test = create(testId, false);
        Representation test2 = create(testId2, true); // this creates and adds the representation
        // now add both and mix Representations that are already present in the yard
        // with an other that is not yet present in the yard

        // change the representations to be sure to force an update even if the
        // implementation checks for changes before updating a representation
        test2.add(field, "test value 2");
        Iterable<Representation> addedIterable = yard.store(Arrays.asList(test, test2));
        assertNotNull(addedIterable);
        Collection<Representation> added = asCollection(addedIterable.iterator());
        // test that both the parsed Representations where stored (updated & created)
        assertTrue(added.remove(test));
        assertTrue(added.remove(test2));
View Full Code Here

Examples of org.apache.stanbol.entityhub.servicesapi.yard.Yard

    @Override
    public final Entity delete(String id) throws EntityhubException, IllegalArgumentException {
        if(id == null || id.isEmpty()){
            throw new IllegalArgumentException("The parsed id MUST NOT be NULL nor emtpty!");
        }
        Yard yard = lookupYard();
        Entity entity = loadEntity(yard, id);
        if(entity != null){
            log.debug("delete Entity {} as requested by the parsed id {}",entity.getId(),id);
            //we need to remove all mappings for this Entity
            deleteMappingsbyTarget(yard,entity.getId());
View Full Code Here

Examples of org.apache.stanbol.entityhub.servicesapi.yard.Yard

    }

    @Test
    public void testStoreRepresentationsWithNullElement() throws YardException {
        String testId = "urn:yard.test.testStoreRepresentationsWithNullElement:representation.id";
        Yard yard = getYard();
        Representation test = create(testId, false);
        Iterable<Representation> added = yard.store(Arrays.asList(test, null));
        // now test that only the valid representation was added and the null
        // value was ignored
        assertNotNull(added);
        Iterator<Representation> addedIt = added.iterator();
        assertTrue(addedIt.hasNext());
View Full Code Here

Examples of org.apache.stanbol.entityhub.servicesapi.yard.Yard

        }
        return entity;
    }
    @Override
    public final void deleteAll() throws EntityhubException {
        Yard yard = lookupYard();
        yard.removeAll();
    }
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.