View Javadoc
1   package de.dlr.shepard.context.references.structureddata.entities;
2   
3   import static org.junit.jupiter.api.Assertions.assertEquals;
4   
5   import de.dlr.shepard.BaseTestCase;
6   import de.dlr.shepard.auth.users.entities.User;
7   import de.dlr.shepard.auth.users.entities.UserGroup;
8   import de.dlr.shepard.context.collection.entities.DataObject;
9   import de.dlr.shepard.context.semantic.entities.SemanticAnnotation;
10  import de.dlr.shepard.context.version.entities.Version;
11  import de.dlr.shepard.data.structureddata.entities.StructuredData;
12  import java.util.Date;
13  import java.util.List;
14  import nl.jqno.equalsverifier.EqualsVerifier;
15  import org.junit.jupiter.api.Test;
16  
17  public class StructuredDataReferenceTest extends BaseTestCase {
18  
19    @Test
20    public void equalsContract() {
21      EqualsVerifier.simple()
22        .forClass(StructuredDataReference.class)
23        .withPrefabValues(DataObject.class, new DataObject(1L), new DataObject(2L))
24        .withPrefabValues(Version.class, new Version("Version1"), new Version("Version2"))
25        .withPrefabValues(User.class, new User("bob"), new User("claus"))
26        .withPrefabValues(UserGroup.class, new UserGroup(1L), new UserGroup(2L))
27        .withPrefabValues(SemanticAnnotation.class, new SemanticAnnotation(1L), new SemanticAnnotation(2L))
28        .verify();
29    }
30  
31    @Test
32    public void addStructuredDataTest() {
33      var ref = new StructuredDataReference(1L);
34      var sd = new StructuredData("newOid", new Date(), "name");
35      ref.addStructuredData(sd);
36  
37      assertEquals(List.of(sd), ref.getStructuredDatas());
38    }
39  }