@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 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 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 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"); }