@Test
public void testUpdateOrganisationUnits()
{

    DataSet dsA = new DataSet( "dsA" );
    OrganisationUnit ouA = new OrganisationUnit( "ouA" );
    OrganisationUnit ouB = new OrganisationUnit( "ouB" );
    OrganisationUnit ouC = new OrganisationUnit( "ouC" );
    OrganisationUnit ouD = new OrganisationUnit( "ouD" );
    dsA.addOrganisationUnit( ouA );
    dsA.addOrganisationUnit( ouB );
    assertEquals( 2, dsA.getSources().size() );
    assertTrue( dsA.getSources().containsAll( Sets.newHashSet( ouA, ouB ) ) );
    assertTrue( ouA.getDataSets().contains( dsA ) );
    assertTrue( ouB.getDataSets().contains( dsA ) );
    assertTrue( ouC.getDataSets().isEmpty() );
    assertTrue( ouD.getDataSets().isEmpty() );
    dsA.updateOrganisationUnits( Sets.newHashSet( ouB, ouC ) );
    assertEquals( 2, dsA.getSources().size() );
    assertTrue( dsA.getSources().containsAll( Sets.newHashSet( ouB, ouC ) ) );
    assertTrue( ouA.getDataSets().isEmpty() );
    assertTrue( ouB.getDataSets().contains( dsA ) );
    assertTrue( ouC.getDataSets().contains( dsA ) );
    assertTrue( ouD.getDataSets().isEmpty() );
}