Beispiel #1
0
  @Test(expected = InvalidEntitySettingsException.class)
  public void shouldSignalInvalidHistoryTrackingSettings() {
    fixDataModel();
    List<EntityDto> entities = getDataModel();
    entities.get(0).setRecordHistory(false);

    EntitySorter.sortByHasARelation(entities, schemaHolder);
  }
Beispiel #2
0
  @Test
  public void shouldProperlySortByInheritance() {
    List<EntityDto> initialList = new ArrayList<>();
    initialList.add(childEntity);
    initialList.add(parentEntity);

    List<EntityDto> entities = EntitySorter.sortByInheritance(initialList);

    Assert.assertTrue(entities.indexOf(parentEntity) < entities.indexOf(childEntity));
  }
Beispiel #3
0
  @Test
  public void shouldProperlySortByHasARelation() {
    fixDataModel();
    List<EntityDto> entities = EntitySorter.sortByHasARelation(getDataModel(), schemaHolder);

    Assert.assertTrue(entities.indexOf(entity3) < entities.indexOf(entity2));
    Assert.assertTrue(entities.indexOf(entity3) < entities.indexOf(entity1));

    Assert.assertTrue(entities.indexOf(entity2) < entities.indexOf(entity1));
    Assert.assertTrue(entities.indexOf(entity2) > entities.indexOf(entity3));
  }
Beispiel #4
0
  @Test
  public void shouldNotSignalErrorOnSelfRelation() {
    fixDataModel();
    List<EntityDto> initialList = new ArrayList<>();
    initialList.addAll(getDataModel());
    initialList.add(binaryTree);

    List<EntityDto> sortingResult = EntitySorter.sortByHasARelation(initialList, schemaHolder);

    Assert.assertEquals(sortingResult.size(), 6);
    Assert.assertTrue(sortingResult.contains(binaryTree));
  }
Beispiel #5
0
 @Test(expected = InvalidRelationshipException.class)
 public void shouldSignalInvalidBidirectionalRelationship() {
   EntitySorter.sortByHasARelation(getDataModel(), schemaHolder);
 }