Search in sources :

Example 1 with LowLevelRecordWithDefault

use of com.linkedin.restli.examples.defaults.api.LowLevelRecordWithDefault in project rest.li by linkedin.

the class FieldFillInDefaultResources method getAllHighLevelRecordWithDefault.

@RestMethod.GetAll
public CollectionResult<HighLevelRecordWithDefault, LowLevelRecordWithDefault> getAllHighLevelRecordWithDefault(@PagingContextParam PagingContext pagingContext) {
    final int total = 3;
    List<HighLevelRecordWithDefault> elements = new LinkedList<>();
    for (int i = 0; i < total; i++) {
        elements.add(new HighLevelRecordWithDefault().setNoDefaultFieldA(i));
    }
    LowLevelRecordWithDefault metadata = new LowLevelRecordWithDefault();
    return new CollectionResult<>(elements, total, metadata);
}
Also used : CollectionResult(com.linkedin.restli.server.CollectionResult) LowLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.LowLevelRecordWithDefault) LinkedList(java.util.LinkedList) HighLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault)

Example 2 with LowLevelRecordWithDefault

use of com.linkedin.restli.examples.defaults.api.LowLevelRecordWithDefault in project rest.li by linkedin.

the class TestFillInDefaultValue method testGetAllData.

@DataProvider(name = "testGetAllData")
private Object[][] testGetAllData() throws CloneNotSupportedException {
    final int count = 3;
    List<HighLevelRecordWithDefault> elements = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        elements.add(new HighLevelRecordWithDefault(expectedTestData.clone()).setNoDefaultFieldA(i));
    }
    CollectionMetadata collectionMetadata = new CollectionMetadata().setCount(10).setTotal(3).setStart(0).setLinks(new LinkArray());
    LowLevelRecordWithDefault metadata = new LowLevelRecordWithDefault();
    metadata.setNameWithDefault(metadata.getNameWithDefault());
    return new Object[][] { { elements, collectionMetadata, metadata } };
}
Also used : CollectionMetadata(com.linkedin.restli.common.CollectionMetadata) LinkArray(com.linkedin.restli.common.LinkArray) ArrayList(java.util.ArrayList) LowLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.LowLevelRecordWithDefault) HighLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault) DataProvider(org.testng.annotations.DataProvider)

Example 3 with LowLevelRecordWithDefault

use of com.linkedin.restli.examples.defaults.api.LowLevelRecordWithDefault in project rest.li by linkedin.

the class TestFillInDefaultValue method testFinderData.

@DataProvider(name = "testFinderData")
private Object[][] testFinderData() throws CloneNotSupportedException {
    final int total = 3;
    List<HighLevelRecordWithDefault> elements = new ArrayList<>();
    for (int i = 0; i < total; i++) {
        elements.add(new HighLevelRecordWithDefault(expectedTestData.clone()).setNoDefaultFieldA(2));
    }
    CollectionMetadata collectionMetadata = new CollectionMetadata().setLinks(new LinkArray()).setCount(10).setTotal(3).setStart(0);
    LowLevelRecordWithDefault metadata = new LowLevelRecordWithDefault();
    metadata.setNameWithDefault(metadata.getNameWithDefault());
    return new Object[][] { { 2, elements, collectionMetadata, metadata } };
}
Also used : CollectionMetadata(com.linkedin.restli.common.CollectionMetadata) LinkArray(com.linkedin.restli.common.LinkArray) ArrayList(java.util.ArrayList) LowLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.LowLevelRecordWithDefault) HighLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault) DataProvider(org.testng.annotations.DataProvider)

Example 4 with LowLevelRecordWithDefault

use of com.linkedin.restli.examples.defaults.api.LowLevelRecordWithDefault in project rest.li by linkedin.

the class TestFillInDefaultValue method testGetAllDataWithoutRequireDefault.

@DataProvider(name = "testGetAllDataWithoutRequireDefault")
private Object[][] testGetAllDataWithoutRequireDefault() throws CloneNotSupportedException {
    final int count = 3;
    List<HighLevelRecordWithDefault> elements = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        elements.add(new HighLevelRecordWithDefault().setNoDefaultFieldA(i));
    }
    CollectionMetadata collectionMetadata = new CollectionMetadata().setLinks(new LinkArray()).setCount(10).setStart(0).setTotal(3);
    LowLevelRecordWithDefault metadata = new LowLevelRecordWithDefault();
    return new Object[][] { { elements, collectionMetadata, metadata } };
}
Also used : CollectionMetadata(com.linkedin.restli.common.CollectionMetadata) LinkArray(com.linkedin.restli.common.LinkArray) ArrayList(java.util.ArrayList) LowLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.LowLevelRecordWithDefault) HighLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault) DataProvider(org.testng.annotations.DataProvider)

Example 5 with LowLevelRecordWithDefault

use of com.linkedin.restli.examples.defaults.api.LowLevelRecordWithDefault in project rest.li by linkedin.

the class FieldFillInDefaultResources method findRecords.

@Finder("findRecords")
public CollectionResult<HighLevelRecordWithDefault, LowLevelRecordWithDefault> findRecords(@QueryParam("noDefaultFieldA") Integer fieldA) {
    final int total = 3;
    List<HighLevelRecordWithDefault> elements = new ArrayList<>();
    for (int i = 0; i < total; i++) {
        HighLevelRecordWithDefault record = new HighLevelRecordWithDefault().setNoDefaultFieldA(fieldA);
        elements.add(record);
    }
    LowLevelRecordWithDefault metadata = new LowLevelRecordWithDefault();
    return new CollectionResult<>(elements, total, metadata);
}
Also used : CollectionResult(com.linkedin.restli.server.CollectionResult) ArrayList(java.util.ArrayList) LowLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.LowLevelRecordWithDefault) HighLevelRecordWithDefault(com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault) Finder(com.linkedin.restli.server.annotations.Finder) BatchFinder(com.linkedin.restli.server.annotations.BatchFinder)

Aggregations

HighLevelRecordWithDefault (com.linkedin.restli.examples.defaults.api.HighLevelRecordWithDefault)5 LowLevelRecordWithDefault (com.linkedin.restli.examples.defaults.api.LowLevelRecordWithDefault)5 ArrayList (java.util.ArrayList)4 CollectionMetadata (com.linkedin.restli.common.CollectionMetadata)3 LinkArray (com.linkedin.restli.common.LinkArray)3 DataProvider (org.testng.annotations.DataProvider)3 CollectionResult (com.linkedin.restli.server.CollectionResult)2 BatchFinder (com.linkedin.restli.server.annotations.BatchFinder)1 Finder (com.linkedin.restli.server.annotations.Finder)1 LinkedList (java.util.LinkedList)1