// Path: tester/src/com/sugaronrest/tester/custommodels/CustomAcccount2.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class CustomAcccount2  extends Accounts {
// 
//     public List<Contacts> getContactLink() {
//         return contactLink;
//     }
// 
//     public void setContactLink(List<Contacts> value) {
//         contactLink = value;
//     }
// 
//     public List<Leads> getLeadLink() {
//         return leadLink;
//     }
// 
//     public void setLeadLink(List<Leads> value) {
//         leadLink = value;
//     }
// 
//     public List<Cases> getCaseLink() {
//         return caseLink;
//     }
// 
//     public void setCaseLink(List<Cases> value) {
//         caseLink = value;
//     }
// 
// 
//     @JsonProperty("contacts")
//     private List<Contacts> contactLink;
// 
//     @JsonProperty("leads")
//     private List<Leads> leadLink;
// 
//     @JsonProperty("cases")
//     private List<Cases> caseLink;
// }


import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sugaronrest.*;
import com.sugaronrest.modules.Accounts;
import com.sugaronrest.modules.Contacts;
import com.sugaronrest.tester.custommodels.CustomAcccount1;
import com.sugaronrest.tester.custommodels.CustomAcccount2;
import com.sugaronrest.tester.helpers.AccountsModule;
import com.sugaronrest.tester.helpers.LinkedModules;
import com.sugaronrest.utils.JsonObjectMapper;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpStatus;
import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.*;

    public static void linkedRead2Test() throws IOException {
        SugarRestClient client = new SugarRestClient(TestAccount.Url, TestAccount.Username, TestAccount.Password);

        // -------------------Bulk Read Account-------------------
        int count = 10;
        SugarRestResponse response = AccountsModule.bulkReadAccount(client, count);

        assertNotNull(response);
        assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

        List<Accounts> readAccounts = (List<Accounts>)response.getData();
        assertNotNull(readAccounts);
        assertTrue(readAccounts.size() <= count);
        // -------------------End Bulk Read Account-------------------


        // -------------------Read Account Link Concat-------------------
        String accountId = readAccounts.get(count - 1).getId();
        response = LinkedModules.readAccountLinkItems(client, accountId);

        assertNotNull(response);
        assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

        String jsonData = response.getJData();
        assertNotNull(jsonData);
        assertNotSame(jsonData, StringUtils.EMPTY );

        // Deserialize json data to custom object
        ObjectMapper mapper = JsonObjectMapper.getMapper();
// Path: tester/src/com/sugaronrest/tester/custommodels/CustomAcccount2.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class CustomAcccount2  extends Accounts {
// 
//     public List<Contacts> getContactLink() {
//         return contactLink;
//     }
// 
//     public void setContactLink(List<Contacts> value) {
//         contactLink = value;
//     }
// 
//     public List<Leads> getLeadLink() {
//         return leadLink;
//     }
// 
//     public void setLeadLink(List<Leads> value) {
//         leadLink = value;
//     }
// 
//     public List<Cases> getCaseLink() {
//         return caseLink;
//     }
// 
//     public void setCaseLink(List<Cases> value) {
//         caseLink = value;
//     }
// 
// 
//     @JsonProperty("contacts")
//     private List<Contacts> contactLink;
// 
//     @JsonProperty("leads")
//     private List<Leads> leadLink;
// 
//     @JsonProperty("cases")
//     private List<Cases> caseLink;
// }


// Path: tester/src/com/sugaronrest/tester/LinkedModulesTests.java
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sugaronrest.*;
import com.sugaronrest.modules.Accounts;
import com.sugaronrest.modules.Contacts;
import com.sugaronrest.tester.custommodels.CustomAcccount1;
import com.sugaronrest.tester.custommodels.CustomAcccount2;
import com.sugaronrest.tester.helpers.AccountsModule;
import com.sugaronrest.tester.helpers.LinkedModules;
import com.sugaronrest.utils.JsonObjectMapper;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpStatus;
import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.*;


    public static void linkedRead2Test() throws IOException {
        SugarRestClient client = new SugarRestClient(TestAccount.Url, TestAccount.Username, TestAccount.Password);

        // -------------------Bulk Read Account-------------------
        int count = 10;
        SugarRestResponse response = AccountsModule.bulkReadAccount(client, count);

        assertNotNull(response);
        assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

        List<Accounts> readAccounts = (List<Accounts>)response.getData();
        assertNotNull(readAccounts);
        assertTrue(readAccounts.size() <= count);
        // -------------------End Bulk Read Account-------------------


        // -------------------Read Account Link Concat-------------------
        String accountId = readAccounts.get(count - 1).getId();
        response = LinkedModules.readAccountLinkItems(client, accountId);

        assertNotNull(response);
        assertEquals(response.getStatusCode(), HttpStatus.SC_OK);

        String jsonData = response.getJData();
        assertNotNull(jsonData);
        assertNotSame(jsonData, StringUtils.EMPTY );

        // Deserialize json data to custom object
        ObjectMapper mapper = JsonObjectMapper.getMapper();
        CustomAcccount2 customAccount = mapper.readValue(jsonData, CustomAcccount2.class);