@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)); }
@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 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 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()); }
@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 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"); }
@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")); }
@Test public void testReplacesManagedIndividual() throws Exception { DataSet dataSet = exampleDataSet(); Individual<?,?> original = dataSet.individualOfId(MANAGED_INDIVIDUAL_ID); Individual<?,?> individual= DataSetUtils. newHelper(dataSet). replace( original.id(), managedIndividualId("other","managerId"), ManagedIndividual.class); assertIsProperlyRenamed(dataSet, original, individual, "managed"); }
@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"); }
@Test public void testReplacesNew() throws Exception { DataSet dataSet = exampleDataSet(); Individual<?,?> original = dataSet.individualOfId(NEW); Individual<?,?> individual= DataSetUtils. newHelper(dataSet). replace( original.id(), managedIndividualId("other","managerId"), ManagedIndividual.class); assertIsProperlyRenamed(dataSet, original, individual, "new"); }
@Test public void testReplacesBlankNode() throws Exception { DataSet dataSet = exampleDataSet(); Individual<?,?> original = dataSet.individualOfId(BLANK_NODE); Individual<?,?> individual= DataSetUtils. newHelper(dataSet). replace( original.id(), managedIndividualId("other","managerId"), ManagedIndividual.class); assertIsProperlyRenamed(dataSet, original, individual, "bnode"); }
@Test public void testReplacesRelativeIndividual() throws Exception { DataSet dataSet = exampleDataSet(); Individual<?,?> original = dataSet.individualOfId(relativeIndividualId(RESOURCE_NAME.id(), MANAGER_ID, RELATIVE_PATH)); Individual<?,?> individual= DataSetUtils. newHelper(dataSet). replace( original.id(), managedIndividualId("other","managerId"), ManagedIndividual.class); assertIsProperlyRenamed(dataSet, original, individual, "relative"); }
withLiteral("bnode"). withLiteral("external"); DataSet original = exampleDataSet(); contains(dataSet, original); contains(original, dataSet);