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

    EntitySorter.sortByHasARelation(entities, schemaHolder);
  }
Exemple #2
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));
  }
Exemple #3
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));
  }
Exemple #4
0
 @Test(expected = InvalidRelationshipException.class)
 public void shouldSignalInvalidBidirectionalRelationship() {
   EntitySorter.sortByHasARelation(getDataModel(), schemaHolder);
 }