package uk.ac.ebi.biosamples.legacy.json.domain;

import uk.ac.ebi.biosamples.model.*;

import java.time.Instant;
import java.util.SortedSet;
import java.util.TreeSet;

public class TestSample {

    private final String accession;
    private String name;
    private Instant releaseDate;
    private SortedSet<Attribute> attributes;
    private SortedSet<Relationship> relationships;
    private SortedSet<ExternalReference> externalReferences;
    private final String testDomain = "testDomain";
    private SortedSet<Organization> organizations;


    public TestSample(String accession) {
        this.accession = accession;
        this.name = "test";
        this.attributes = new TreeSet<>();
        this.relationships = new TreeSet<>();
        this.externalReferences = new TreeSet<>();
        this.organizations = new TreeSet<>();
        this.releaseDate = Instant.now();
    }

    public TestSample withName(String name) {
        this.name = name;
        return this;
    }

    public TestSample withAttribute(Attribute attribute) {
        this.attributes.add(attribute);
        return this;
    }

    public TestSample withRelationship(Relationship rel) {
        this.relationships.add(rel);
        return this;
    }

    public TestSample releasedOn(Instant releaseDate) {
        this.releaseDate = releaseDate;
        return this;
    }

    public TestSample withExternalReference(ExternalReference ref) {
        this.externalReferences.add(ref);
        return this;
    }

    public TestSample withOrganization(Organization org) {
        this.organizations.add(org);
        return this;
    }

    public Sample build() {
        return Sample.build(this.name,
                this.accession,
                this.testDomain,
                this.releaseDate,
                Instant.now(),
                this.attributes,
                this.relationships,
                this.externalReferences,
                this.organizations);
    }
}

@@ -543,16 +543,106 @@
 ations;%0A
+    private SortedSet%3CContact%3E contacts;%0A    private SortedSet%3CPublication%3E publications;%0A
 %0A%0A    pu
@@ -919,32 +919,118 @@
 ew TreeSet%3C%3E();%0A
+        this.contacts = new TreeSet%3C%3E();%0A        this.publications = new TreeSet%3C%3E();%0A
         this.rel
@@ -2141,16 +2141,82 @@
 izations
+,%0A                this.contacts,%0A                this.publications
 );%0A    %7D

add contacts and publication to legacy json test sample