@Test public void Namespaces() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addClass(TEST.NS, Labeled.class) .addProperty("label", RDFS.label) .addProperty("comment", RDFS.comment); Configuration configuration = builder.build(); // labeled MappedClass labeled = configuration.getMappedClass(Labeled.class); MappedPath labeled_label = labeled.getMappedPath("label"); assertEquals(RDFS.label, labeled_label.getPredicatePath().get(0).getUID()); MappedPath labeled_comment = labeled.getMappedPath("comment"); assertEquals(RDFS.comment, labeled_comment.getPredicatePath().get(0).getUID()); }
@Test public void AddProperty() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addClass(TEST.NS, Person.class) .addId("id") .addProperty("firstName") .addProperty("lastName", new UID(TEST.NS, "surName")) .addProperty("superior") .addProperty("department"); Configuration configuration = builder.build(); // person MappedClass person = configuration.getMappedClass(Person.class); MappedPath person_id = person.getMappedPath("id"); assertTrue(person_id.getPredicatePath().isEmpty()); MappedPath person_firstName = person.getMappedPath("firstName"); assertEquals(TEST.NS, person_firstName.getPredicatePath().get(0).getUID().ns()); assertEquals("firstName", person_firstName.getPredicatePath().get(0).getUID().ln()); MappedPath person_lastName = person.getMappedPath("lastName"); assertEquals("surName", person_lastName.getPredicatePath().get(0).getUID().ln()); MappedPath person_superior = person.getMappedPath("superior"); assertEquals("superior", person_superior.getPredicatePath().get(0).getUID().ln()); MappedPath person_department = person.getMappedPath("department"); assertEquals("department", person_department.getPredicatePath().get(0).getUID().ln()); }
@Test public void Inverse() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addClass(TEST.NS, Company.class) .addId("id") .addProperty("departments", new UID(TEST.NS, "company"), true) .addProperties(); Configuration configuration = builder.build(); // company MappedClass company = configuration.getMappedClass(Company.class); MappedPath company_departments = company.getMappedPath("departments"); assertEquals(TEST.NS, company_departments.getPredicatePath().get(0).getUID().ns()); assertEquals("company", company_departments.getPredicatePath().get(0).getUID().ln()); assertTrue(company_departments.getPredicatePath().get(0).inv()); }
@Test public void Container() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addClass(TEST.NS, Company.class) .addId("id") .addProperty("departments", new UID(TEST.NS, "company"), ContainerType.SEQ) .addProperties(); Configuration configuration = builder.build(); // company MappedClass company = configuration.getMappedClass(Company.class); MappedPath company_departments = company.getMappedPath("departments"); assertEquals(TEST.NS, company_departments.getPredicatePath().get(0).getUID().ns()); assertEquals("company", company_departments.getPredicatePath().get(0).getUID().ln()); assertEquals(ContainerType.SEQ, company_departments.getMappedProperty().getContainerType()); }
@Test public void Localized() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addClass(TEST.NS, Labeled.class) .addLocalized("label", RDFS.label) .addProperty("comment", RDFS.comment); Configuration configuration = builder.build(); // labeled MappedClass labeled = configuration.getMappedClass(Labeled.class); MappedPath labeled_label = labeled.getMappedPath("label"); assertTrue(labeled_label.getMappedProperty().isLocalized()); assertEquals(RDFS.label, labeled_label.getPredicatePath().get(0).getUID()); MappedPath labeled_comment = labeled.getMappedPath("comment"); assertFalse(labeled_comment.getMappedProperty().isLocalized()); assertEquals(RDFS.comment, labeled_comment.getPredicatePath().get(0).getUID()); }