@Test public void testCreatesLocalIndividualIfItDoesNotExist() throws Exception { DataSet dataSet = exampleDataSet(); DataSetUtils. newHelper(dataSet). localIndividual(name("other")); Individual<?,?> individual = dataSet. individualOfId(name("other")); assertThat(individual,notNullValue()); }
@Test public void testCreatesManagedIndividualIfItDoesNotExist() throws Exception { DataSet dataSet = exampleDataSet(); DataSetUtils. newHelper(dataSet). managedIndividual(name("other"),MANAGER_ID); Individual<?,?> individual = dataSet. individualOfId(managedIndividualId("other", MANAGER_ID)); assertThat(individual,notNullValue()); }
@Test public void testCreatesRelativeIndividualIfItDoesNotExist() throws Exception { DataSet dataSet = exampleDataSet(); DataSetUtils. newHelper(dataSet). relativeIndividual(name("other"),MANAGER_ID,RELATIVE_PATH); Individual<?,?> individual = dataSet. individualOfId(relativeIndividualId("other", MANAGER_ID, RELATIVE_PATH)); assertThat(individual,notNullValue()); }
DataSetHelper helper = DataSetUtils.newHelper(dataSet); helper. managedIndividual(RESOURCE_NAME, MANAGER_ID). property(HAS_TITLE). withLiteral("managed"). withIndividual(RESOURCE_NAME, MANAGER_ID); helper. relativeIndividual(RESOURCE_NAME, MANAGER_ID,RELATIVE_PATH). property(HAS_TITLE). withLiteral("relative"). withIndividual(RESOURCE_NAME, MANAGER_ID,RELATIVE_PATH); helper. localIndividual(BLANK_NODE). property(HAS_TITLE). withLiteral("bnode"). withIndividual(BLANK_NODE); helper. externalIndividual(SELF). property(HAS_TITLE). withLiteral("self"). withIndividual(SELF); helper. externalIndividual(NEW). property(HAS_TITLE). withLiteral("new").
managedIndividual(serviceName, ServiceHandler.ID). property(TYPE). withIndividual(DC_TYPE_SERVICE_TYPE). relativeIndividual(serviceName,ServiceHandler.ID,VOCABULARY_PATH). property(TYPE). withIndividual(CI_VOCABULARY_TYPE).
DataSetHelper helper = DataSetUtils.newHelper(dataSet); helper. managedIndividual(name("unknown"),"managerId"). property(RDFS.LABEL). withLiteral("label"). withIndividual("unknown"); helper. localIndividual(name("unknown")). property(RDFS.LABEL). withLiteral("label").
@Test public void testDoesNotReplacesUnknown() throws Exception { DataSet dataSet = exampleDataSet(); Individual<?,?> individual= DataSetUtils. newHelper(dataSet). replace( managedIndividualId("other","managerId"), managedIndividualId("another","managerId"), ManagedIndividual.class); assertThat(individual,nullValue()); }
@Test(expected=DataSetModificationException.class) public void testCannotManagedUsingAnExistingManagedIndividual() throws Exception { DataSet dataSet = exampleDataSet(); DataSetUtils. newHelper(dataSet). manage(MANAGED_INDIVIDUAL_ID); }
@Test public void testSelf() throws Exception { DataSet dataSet = exampleDataSet(); DataSetHelper newHelper = DataSetUtils.newHelper(dataSet); Individual<?,?> self = newHelper.self(); assertThat(self.property(URI.create(HAS_TITLE)).hasLiteralValue(Literals.of("self")),equalTo(true)); }
@Override public DataSet get(final ResourceSnapshot resource) { final DataSet dataSet=DataSets.createDataSet(resource.name()); final DataSetHelper helper=DataSetUtils.newHelper(dataSet); helper. managedIndividual(resource.name(), ID). property(RDF.TYPE). withIndividual(DCTYPE.SERVICE_TYPE). withIndividual(PLATFORM.MICRO_SERVICE_TYPE). withIndividual(PLATFORM.LINKED_DATA_MICRO_SERVICE_TYPE). withIndividual(PLATFORM.HARVESTER_TYPE). withIndividual(IT.HARVESTER_TYPE). property(PLATFORM.HARVESTER_VOCABULARY). withIndividual(resource.name(),HarvesterHandler.ID,VOCABULARY_PATH); helper. relativeIndividual(resource.name(),HarvesterHandler.ID,VOCABULARY_PATH). property(RDF.TYPE). withIndividual(IT.VOCABULARY_TYPE). withIndividual(PLATFORM.VOCABULARY_TYPE). property(PLATFORM.SOURCE). withLiteral(IT.sourceCode()). property(DCTERMS.SOURCE). withLiteral(IT.sourceCode()). property(PLATFORM.IMPLEMENTS). withIndividual(IT.DOMAIN_TYPE); return dataSet; }
@Test public void testDoesNotReplacesItself() throws Exception { DataSet dataSet = exampleDataSet(); Individual<?,?> individual= DataSetUtils. newHelper(dataSet). replace( managedIndividualId("other","managerId"), managedIndividualId("other","managerId"), ManagedIndividual.class); assertThat(individual,nullValue()); }
@Test public void testManagesSelf() throws Exception { DataSet dataSet = exampleDataSet(); Individual<?,?> original = dataSet.individualOfId(SELF); Individual<?,?> individual= DataSetUtils. newHelper(dataSet). manage(managedIndividualId("other","managerId")); assertIsProperlyRenamed(dataSet, original, individual, "self"); }
final IndividualPropertyHelper executionHelper = helper. managedIndividual(executionName,ExecutionHandler.ID). property(TYPE). withIndividual(AUTO_AUTOMATION_REQUEST). relativeIndividual(executionName,ExecutionHandler.ID,RESULT_PATH). property(TYPE). withIndividual(AUTOMATION_RESULT).
@Test public void testDataDSL() { Date date=new Date(); Name<String> name = NamingScheme.getDefault().name("name"); DataSet initialData = getInitialData(TEMPLATE_ID,name.id(),false,date); DataSetHelper helper=DataSetUtils.newHelper(initialData); DateTime firstValue= helper. managedIndividual(name,TEMPLATE_ID). property(READ_ONLY_PROPERTY). firstValue(DateTime.class); assertThat(firstValue,notNullValue()); assertThat(TimeUtils.newInstance().from(firstValue).toDate(),equalTo(date)); }
private void populateChangeLog(final Issue issue, final Name<String> changeLogName, final DataSetHelper helper) { final IndividualHelper changeLog = helper. localIndividual(changeLogName). property(RDF.TYPE). withIndividual(IT.CHANGE_LOG_TYPE); if(issue.getChanges()==null) { return; } int entryCount=0; for(final Entry entry:issue.getChanges().getEntries()) { final Name<String> entryName= NamingScheme. getDefault(). name( changeLogName.id(), "entry", Integer.toString(entryCount++)); populateChangeLogEntry(issue,entry,entryName,helper,changeLog); } }
replace( DataSetHelper.SELF, ManagedIndividualId.createId(name,PersonHandler.ID),
@Test(expected=DataSetModificationException.class) public void testCannotManageIfSelfDoesNotExist() throws Exception { DataSet dataSet = exampleDataSet(); Individual<?,?> original = dataSet.individualOfId(SELF); dataSet.remove(original); DataSetUtils. newHelper(dataSet). manage(managedIndividualId("other","managerId")); }
@Override protected DataSet toDataSet(final Contributor contributor, final String contributorId) { final Name<String> contributorName=IdentityUtil.contributorName(contributorId); final DataSet dataSet=DataSets.createDataSet(contributorName); final DataSetHelper helper=DataSetUtils.newHelper(dataSet); final IndividualPropertyHelper individual= helper. managedIndividual(contributorName,ContributorHandler.ID). property(RDF.TYPE). withIndividual(IT.CONTRIBUTOR_TYPE). property(IT.ID). withLiteral(contributor.getId()). property(IT.CONTRIBUTOR_ID). withLiteral(contributor.getId()). property(IT.CONTRIBUTOR_NAME). withLiteral(contributor.getName()); for(final String email:contributor.getEmails()) { individual. property(IT.MBOX). withLiteral(URI.create(email)); } return dataSet; }
@Test public void testGetDescription$failureRequest$otherPath() throws Exception { Name<?> id = NamingScheme.getDefault().name("Test"); Query query = QueryBuilder. newInstance(). withParameter(QueryableResourceHandler.FAILURE, "FALSE"). build(); DataSet data=QuerySupport.getDescription(id, query); assertThat((Object)data.name(),sameInstance((Object)id)); DataSetHelper dHelper = DataSetUtils.newHelper(data); IndividualHelper qInd = dHelper.localIndividual(QuerySupport.queryId()); assertThat(qInd.types(),contains(QuerySupport.QUERY_TYPE)); IndividualHelper pInd = dHelper.localIndividual(QuerySupport.parameterId(QueryableResourceHandler.FAILURE)); assertThat(pInd.types(),contains(QuerySupport.PARAMETER_TYPE)); }
@Test public void testReplacesSelf() throws Exception { DataSet dataSet = exampleDataSet(); Individual<?,?> original = dataSet.individualOfId(SELF); Individual<?,?> individual= DataSetUtils. newHelper(dataSet). replace( original.id(), managedIndividualId("other","managerId"), ManagedIndividual.class); assertIsProperlyRenamed(dataSet, original, individual, "self"); }