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

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