Exemple #1
0
  @Before
  public void setUpEntities() {
    book = new EntityDto("Book");
    author = new EntityDto("Author");

    authorFieldInBook = fieldDto("author", ManyToManyRelationship.class);
    authorFieldInBook.addMetadata(new MetadataDto(RELATED_CLASS, "Author"));

    FieldDto bookFieldInAuthor = fieldDto("book", ManyToManyRelationship.class);
    bookFieldInAuthor.addMetadata(new MetadataDto(RELATED_CLASS, "Book"));

    when(schemaHolder.getFields(book)).thenReturn(singletonList(authorFieldInBook));
    when(schemaHolder.getFields(author)).thenReturn(singletonList(bookFieldInAuthor));

    entity1 = new EntityDto("Entity1");
    entity2 = new EntityDto("Entity2");
    entity3 = new EntityDto("Entity3");

    FieldDto entity1Field = fieldDto("entity1", OneToOneRelationship.class);
    entity1Field.addMetadata(new MetadataDto(RELATED_CLASS, "Entity2"));

    FieldDto entity2Field = fieldDto("entity2", OneToOneRelationship.class);
    entity2Field.addMetadata(new MetadataDto(RELATED_CLASS, "Entity3"));

    when(schemaHolder.getFields(entity1)).thenReturn(singletonList(entity1Field));
    when(schemaHolder.getFields(entity2)).thenReturn(singletonList(entity2Field));

    parentEntity = new EntityDto("Parent");
    childEntity = new EntityDto("Child");
    childEntity.setSuperClass("Parent");

    binaryTree = new EntityDto("Binary tree");
    FieldDto leftChild = fieldDto("leftChild", "Left child", OneToOneRelationship.class);
    leftChild.addMetadata(new MetadataDto(RELATED_CLASS, "Binary tree"));

    FieldDto rightChild = fieldDto("rightChild", "Right child", OneToOneRelationship.class);
    rightChild.addMetadata(new MetadataDto(RELATED_CLASS, "Binary tree"));

    when(schemaHolder.getFields(binaryTree)).thenReturn(asList(leftChild, rightChild));

    entity1.setRecordHistory(true);
    entity2.setRecordHistory(true);
    entity3.setRecordHistory(true);
    book.setRecordHistory(true);
    author.setRecordHistory(true);
    parentEntity.setRecordHistory(true);
    childEntity.setRecordHistory(true);
    binaryTree.setRecordHistory(true);
  }