diff --git a/modules/odata/odata-api/src/main/java/org/eclipse/dirigible/engine/odata2/api/IODataCoreService.java b/modules/odata/odata-api/src/main/java/org/eclipse/dirigible/engine/odata2/api/IODataCoreService.java index c9ad54ea981..9b83e45bce6 100644 --- a/modules/odata/odata-api/src/main/java/org/eclipse/dirigible/engine/odata2/api/IODataCoreService.java +++ b/modules/odata/odata-api/src/main/java/org/eclipse/dirigible/engine/odata2/api/IODataCoreService.java @@ -269,9 +269,9 @@ public interface IODataCoreService extends ICoreService { /** * Getter for the OData entity * - * @param location - * @return - * @throws ODataException + * @param location the location + * @return ODataDefinition + * @throws ODataException in case of an error */ public ODataDefinition getOData(String location) throws ODataException; @@ -382,7 +382,7 @@ public interface IODataCoreService extends ICoreService { /** * Removes the handlers * - * @param location + * @param location the location * @throws ODataException in case of an error */ public void removeHandlers(String location) throws ODataException; diff --git a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/AbstractSQLPropcessorTest.java b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/AbstractSQLPropcessorTest.java index 7743422ad9e..de4164a7c27 100644 --- a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/AbstractSQLPropcessorTest.java +++ b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/AbstractSQLPropcessorTest.java @@ -93,7 +93,7 @@ public DataSource createDataSource() { } - protected String loadExpectedData(String fileName) throws IOException { + protected String loadResource(String fileName) throws IOException { return IOUtils.toString(AbstractSQLPropcessorTest.class.getResourceAsStream(fileName), Charset.defaultCharset()); } diff --git a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2RequestBuilder.java b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2RequestBuilder.java index 68aa275921c..a3a35ed10e3 100644 --- a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2RequestBuilder.java +++ b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2RequestBuilder.java @@ -43,7 +43,6 @@ import org.apache.olingo.odata2.api.ODataServiceFactory; import org.apache.olingo.odata2.api.commons.ODataHttpMethod; import org.apache.olingo.odata2.api.exception.ODataException; -import org.apache.olingo.odata2.api.processor.ODataRequest.ODataRequestBuilder; import org.apache.olingo.odata2.core.rest.ODataSubLocator; import org.apache.olingo.odata2.core.rest.SubLocatorParameter; import org.easymock.Capture; @@ -56,10 +55,10 @@ /** * Base class for OData API tests, which can be used to simulate calls to the OData API without having to use a servlet. * - * In order to use the class, inherit from it and overwrite the {@link ODataRequestBuilder#getServiceFactoryClass()} method. You can use + * In order to use the class, inherit from it and overwrite the {@link OData2RequestBuilder#executeRequest(ODataHttpMethod)} method. You can use * this method also to provide mock data to your API. If you API retrieves handles to data sources via the servlet context or the servlet - * request, use the {@link ODataRequestBuilder#enrichServletContextMock(ServletContext)} and - * {@link ODataRequestBuilder#enrichServletRequestMock(ServletRequest)} methods to provide the handles to you mock data. + * request, use the {@link OData2RequestBuilder#enrichServletContextMock(ServletContext)} and + * {@link OData2RequestBuilder#enrichServletRequestMock(ServletRequest)} methods to provide the handles to you mock data. * */ public class OData2RequestBuilder { @@ -76,35 +75,65 @@ public class OData2RequestBuilder { private int contentSize = 1024 * 4; private ODataServiceFactory serviceFactory; + /** + * @param pathSegmentStrings the path + * @return OData2RequestBuilder + */ public OData2RequestBuilder segments(final String... pathSegmentStrings) { pathSegmentStringList.addAll(Arrays.asList(pathSegmentStrings)); return this; } + /** + * @param name the param name + * @param value the param value + * @return OData2RequestBuilder + */ public OData2RequestBuilder param(final String name, final String value) { queryParams.add(name, value); return this; } + /** + * @param accept the accept header + * @return OData2RequestBuilder + */ public OData2RequestBuilder accept(final String accept) { this.accept = accept; return this; } + /** + * @param contentSize the contentSize header + * @return OData2RequestBuilder + */ public OData2RequestBuilder contentSize(final int contentSize) { this.contentSize = contentSize; return this; } + /** + * @return executeRequest + * @throws IOException in case of error + * @throws ODataException in case of error + */ public Response executeRequest() throws IOException, ODataException { return executeRequest(GET); } + /** + * @param serviceFactory serviceFactory + * @return OData2RequestBuilder + */ public OData2RequestBuilder serviceFactory(ODataServiceFactory serviceFactory) { this.serviceFactory = serviceFactory; return this; } + /** + * @param sf ODataServiceFactory + * @return OData2RequestBuilder + */ public static OData2RequestBuilder createRequest(ODataServiceFactory sf) { final OData2RequestBuilder request = new OData2RequestBuilder(); return request.serviceFactory(sf); @@ -117,10 +146,8 @@ public static OData2RequestBuilder createRequest(ODataServiceFactory sf) { * Mandatory parameter defining Http Method to be used for the request. Expected values are: GET, PUT, POST, DELETE, PATCH, * MERGE * @return OData Response - * @throws InstantiationException - * @throws IllegalAccessException - * @throws IOException - * @throws ODataException + * @throws IOException in case of error + * @throws ODataException in case of error */ public Response executeRequest(final ODataHttpMethod method) throws IOException, ODataException { @@ -221,6 +248,12 @@ public List answer() throws Throwable { return response; } + /** + * @param method the method + * @param easyMockSupport the easyMockSupport + * @param servletRequest the servletRequest + * @throws IOException in case of error + */ protected void getServletInputStream(final ODataHttpMethod method, final EasyMockSupport easyMockSupport, final HttpServletRequest servletRequest) throws IOException { @SuppressWarnings("resource") @@ -237,6 +270,10 @@ protected void getServletInputStream(final ODataHttpMethod method, final EasyMoc expect(servletRequest.getInputStream()).andReturn(contentInputStream).atLeastOnce(); } + /** + * @param content the content + * @return OData2RequestBuilder + */ public OData2RequestBuilder content(@SuppressWarnings("unused") final String content) { //NOSONAR to be overridden by subclasses return this; } @@ -247,7 +284,7 @@ public OData2RequestBuilder content(@SuppressWarnings("unused") final String con * * @param servletContext * the EasyMock instance of the {@link ServletContext}. - * @throws Exception + * @throws ODataException in case of error */ protected void enrichServletContextMock(final ServletContext servletContext) throws ODataException { // default implementation is empty diff --git a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2TestServiceFactory.java b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2TestServiceFactory.java index 7cd6e95c83a..2f3a6e4c7be 100644 --- a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2TestServiceFactory.java +++ b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2TestServiceFactory.java @@ -28,26 +28,49 @@ import static org.eclipse.dirigible.engine.odata2.sql.processor.DefaultSQLProcessor.DEFAULT_DATA_SOURCE_CONTEXT_KEY; +/** + * OData2TestServiceFactory + * + */ public class OData2TestServiceFactory extends org.apache.olingo.odata2.api.ODataServiceFactory { private final DataSource ds; private final Class[] edmAnnotatedClasses; private final List interceptorList = new ArrayList<>(); + /** + * @param ds the data source + * @param edmAnnotatedClasses the classes + * @throws ODataException in case of error + */ public OData2TestServiceFactory(DataSource ds, Class... edmAnnotatedClasses) throws ODataException { this(ds, Collections.emptyList(), edmAnnotatedClasses); } + + /** + * @param ds the data source + * @param interceptorList the interceptor list + * @param edmAnnotatedClasses the classes + * @throws ODataException in case of error + */ public OData2TestServiceFactory(DataSource ds, List interceptorList, Class... edmAnnotatedClasses) throws ODataException { this.ds = ds; this.edmAnnotatedClasses = edmAnnotatedClasses; addInterceptors(interceptorList); } + /** + * @return AnnotationEdmProvider + * @throws ODataException in case of error + */ public AnnotationEdmProvider createAnnotationEdmProvider() throws ODataException { return new AnnotationEdmProvider(Collections.unmodifiableList(Arrays.asList(edmAnnotatedClasses))); } + /** + * @param interceptorList the interceptor list + */ public void addInterceptors(List interceptorList){ this.interceptorList.addAll(interceptorList); } @@ -67,6 +90,10 @@ public ODataService createService(ODataContext ctx) throws ODataException { } } + /** + * @param ctx the context + * @throws ODataException in case of error + */ public void setDefaultDataSource(ODataContext ctx) throws ODataException { ctx.setParameter(DEFAULT_DATA_SOURCE_CONTEXT_KEY, ds); } diff --git a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2TestUtils.java b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2TestUtils.java index 19d95f04b5d..14205ff9a0b 100644 --- a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2TestUtils.java +++ b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/OData2TestUtils.java @@ -31,7 +31,6 @@ import org.apache.olingo.odata2.api.ep.feed.ODataFeed; import org.apache.olingo.odata2.api.exception.ODataException; import org.apache.olingo.odata2.api.processor.ODataErrorContext; -import org.apache.olingo.odata2.api.processor.ODataRequest.ODataRequestBuilder; import liquibase.Contexts; import liquibase.LabelExpression; @@ -43,21 +42,25 @@ import liquibase.exception.LiquibaseException; import liquibase.resource.ClassLoaderResourceAccessor; +/** + * OData2TestUtils + * + */ public class OData2TestUtils { private OData2TestUtils() { } /** - * Helper method to retrieve the {@link ODataEntry} from the response object returned by {@link ODataRequestBuilder#executeRequest()}. + * Helper method to retrieve the {@link ODataEntry} from the response object returned by {@link OData2RequestBuilder#executeRequest()}. * * @param response - * the response returned by {@link ODataRequestBuilder#executeRequest()} + * the response returned by {@link OData2RequestBuilder#executeRequest()} * @param entitySet * the {@link EdmEntitySet} used to parse the response * @return the {@link ODataEntry} - * @throws IOException - * @throws ODataException + * @throws IOException in case of error + * @throws ODataException in case of error */ public static ODataEntry retrieveODataEntryFromResponse(final Response response, final EdmEntitySet entitySet) throws IOException, ODataException { @@ -70,15 +73,15 @@ public static ODataEntry retrieveODataEntryFromResponse(final Response response, } /** - * Helper method to retrieve the {@link ODataFeed} from the response object returned by {@link ODataRequestBuilder#executeRequest()}. + * Helper method to retrieve the {@link ODataFeed} from the response object returned by {@link OData2RequestBuilder#executeRequest()}. * * @param response - * the response returned by {@link ODataRequestBuilder#executeRequest()} + * the response returned by {@link OData2RequestBuilder#executeRequest()} * @param entitySet * the {@link EdmEntitySet} used to parse the response * @return the {@link ODataFeed} - * @throws IOException - * @throws ODataException + * @throws IOException in case of error + * @throws ODataException in case of error */ public static ODataFeed retrieveODataFeedFromResponse(final Response response, final EdmEntitySet entitySet) throws IOException, ODataException { @@ -92,14 +95,14 @@ public static ODataFeed retrieveODataFeedFromResponse(final Response response, f /** * Helper method to retrieve the {@link ODataErrorContext} representing the error response to a failed call to an OData API from the - * response object returned by {@link ODataRequestBuilder#executeRequest()}. + * response object returned by {@link OData2RequestBuilder#executeRequest()}. * * @param response * the object containing the error response * @return the ODataErrorContext representing the content of the returned error document. NOTE: The used parser does not parse * the message's locale so it will always be null. - * @throws IOException - * @throws EntityProviderException + * @throws IOException in case of error + * @throws EntityProviderException in case of error */ public static ODataErrorContext retrieveODataErrorDocumentFromResponse(final Response response) throws IOException, EntityProviderException { @@ -108,10 +111,19 @@ public static ODataErrorContext retrieveODataErrorDocumentFromResponse(final Res } } + /** + * @param ns the namespace + * @param name the name + * @return FQN + */ public static String fqn(String ns, String name) { return ns + "." + name; } + /** + * @param clazz the class + * @return FQN + */ public static String fqn(Class clazz) { AnnotationHelper annotationHelper = new AnnotationHelper(); FullQualifiedName fqn = null; @@ -128,6 +140,10 @@ public static String fqn(Class clazz) { return fqn.toString(); } + /** + * @param classes the classes + * @return list + */ public static List fqns(Class... classes) { List fqns = new ArrayList(); for (Class clazz : classes) { @@ -136,6 +152,10 @@ public static List fqns(Class... classes) { return fqns; } + /** + * @param classes the classes + * @return array + */ @SuppressWarnings("rawtypes") public static String[] resources(Class... classes) { List resources = new ArrayList<>(); @@ -145,14 +165,28 @@ public static String[] resources(Class... classes) { return resources.toArray(new String[resources.size()]); } + /** + * @param T + * @param clazz class + * @return content + */ public static String resource(Class clazz) { return "META-INF/" + clazz.getSimpleName() + ".json"; } + /** + * @param T + * @param clazz class + * @return InputStream + */ public static InputStream stream(Class clazz) { return OData2TestUtils.class.getClassLoader().getResourceAsStream(resource(clazz)); } + /** + * @param ds data source + * @throws SQLException in case of error + */ public static void initLiquibase(DataSource ds) throws SQLException { try (Connection connection = ds.getConnection()) { Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection)); diff --git a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/builder/SQLQueryTestUtils.java b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/builder/SQLQueryTestUtils.java index aebebb2dbb9..d1e27597540 100644 --- a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/builder/SQLQueryTestUtils.java +++ b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/builder/SQLQueryTestUtils.java @@ -13,6 +13,10 @@ import org.apache.olingo.odata2.api.edm.EdmStructuralType; +/** + * SQLQueryTestUtils + * + */ public class SQLQueryTestUtils { private SQLQueryTestUtils() { @@ -20,8 +24,8 @@ private SQLQueryTestUtils() { } /** - * @param sqlQuery - * @param structuralType + * @param sqlQuery the query + * @param structuralType the type */ public static void grantTableAliasForStructuralTypeInQuery(final SQLSelectBuilder sqlQuery, final EdmStructuralType structuralType) { sqlQuery.grantTableAliasForStructuralTypeInQuery(structuralType); diff --git a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/test/util/OData2TestUtils.java b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/test/util/OData2TestUtils.java index 3ae888d65e0..f204d6ff7e0 100644 --- a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/test/util/OData2TestUtils.java +++ b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/test/util/OData2TestUtils.java @@ -30,6 +30,10 @@ import org.apache.olingo.odata2.api.exception.ODataException; import org.apache.olingo.odata2.api.processor.ODataErrorContext; +/** + * OData2TestUtils + * + */ public class OData2TestUtils { private OData2TestUtils() { @@ -37,16 +41,16 @@ private OData2TestUtils() { /** * Helper method to retrieve the {@link ODataEntry} from the response object - * returned by {@link ODataRequestBuilder#executeRequest()}. + * returned by OData2RequestBuilder#executeRequest(). * * @param response * the response returned by - * {@link ODataRequestBuilder#executeRequest()} + * OData2RequestBuilder#executeRequest() * @param entitySet - * the {@link EdmEntitySet} used to parse the response - * @return the {@link ODataEntry} - * @throws IOException - * @throws ODataException + * the EdmEntitySet used to parse the response + * @return the ODataEntry + * @throws IOException in case of error + * @throws ODataException in case of error */ public static ODataEntry retrieveODataEntryFromResponse(final Response response, final EdmEntitySet entitySet) throws IOException, ODataException { @@ -59,17 +63,17 @@ public static ODataEntry retrieveODataEntryFromResponse(final Response response, } /** - * Helper method to retrieve the {@link ODataFeed} from the response object - * returned by {@link ODataRequestBuilder#executeRequest()}. + * Helper method to retrieve the ODataFeed from the response object + * returned by OData2RequestBuilder#executeRequest(). * * @param response * the response returned by - * {@link ODataRequestBuilder#executeRequest()} + * OData2RequestBuilder#executeRequest() * @param entitySet - * the {@link EdmEntitySet} used to parse the response - * @return the {@link ODataFeed} - * @throws IOException - * @throws ODataException + * the EdmEntitySet used to parse the response + * @return the ODataFeed + * @throws IOException in case of error + * @throws ODataException in case of error */ public static ODataFeed retrieveODataFeedFromResponse(final Response response, final EdmEntitySet entitySet) throws IOException, ODataException { @@ -82,17 +86,17 @@ public static ODataFeed retrieveODataFeedFromResponse(final Response response, f } /** - * Helper method to retrieve the {@link ODataErrorContext} representing the + * Helper method to retrieve the ODataErrorContext representing the * error response to a failed call to an OData API from the response object - * returned by {@link ODataRequestBuilder#executeRequest()}. + * returned by OData2RequestBuilder#executeRequest(). * * @param response * the object containing the error response * @return the ODataErrorContext representing the content of the returned * error document. NOTE: The used parser does not parse the * message's locale so it will always be null. - * @throws IOException - * @throws EntityProviderException + * @throws IOException in case of error + * @throws EntityProviderException in case of error */ public static ODataErrorContext retrieveODataErrorDocumentFromResponse(final Response response) throws IOException, EntityProviderException { @@ -102,10 +106,10 @@ public static ODataErrorContext retrieveODataErrorDocumentFromResponse(final Res } /** - * Validates an {@link ODataFeed} against a list of Maps, which represents + * Validates an ODataFeed against a list of Maps, which represents * the expected properties of each entry. The expected properties define * only a minimal set of properties, which have to be contained in the - * {@link ODataEntry}s. The {@link ODataEntry}s can contain more entries. + * ODataEntrys. The ODataEntrys can contain more entries. * The properties of the entries itself can contain entries or maps, which * are validated recursively. The validation is independent of the order of * the entries. The result is returned as a {@link Pair}, where the first @@ -114,10 +118,10 @@ public static ODataErrorContext retrieveODataErrorDocumentFromResponse(final Res * * @param expectedEntries * a list of maps which represent the expected properties of the - * {@link ODataEntry}s + * ODataEntrys * @param oDataFeed - * an {@link ODataFeed}, which shall be validated - * @return a Pair, where the first member is true or false + * an ODataFeed, which shall be validated + * @return a Pair where the first member is true or false * depending on the result of the validation and the second gives * the reason, if the validation has failed */ @@ -127,19 +131,19 @@ public static Pair validateODataFeed(final List, where the first member is true or false + * an ODataEntry, which shall be validated + * @return a Pair, where the first member is true or false * depending on the result of the validation and the second gives * the reason, if the validation has failed */ @@ -184,9 +188,9 @@ else if (expectedValue instanceof Map) { } /** - * @param expectedValueList - * @param actualValueList - * @return + * @param expectedValueList expected + * @param actualValueList actual + * @return Pair */ private static Pair validateODataFeed(final List> expectedValueList, final List actualValueList) { @@ -208,9 +212,9 @@ private static Pair validateODataFeed(final List validateODataEntry(final Map expectedProperties, final Map actualProperties) { @@ -223,10 +227,19 @@ private static Pair validateODataEntry(final Map(true, "Success"); } + /** + * @param ns the namespace + * @param name the name + * @return FQN + */ public static String fqn(String ns, String name) { return ns + "." + name; } + /** + * @param clazz class + * @return FQN + */ public static String fqn(Class clazz) { AnnotationHelper annotationHelper = new AnnotationHelper(); FullQualifiedName fqn = null; @@ -243,6 +256,10 @@ public static String fqn(Class clazz) { return fqn.toString(); } + /** + * @param classes classes + * @return FQN list + */ public static List fqns(Class... classes) { List fqns = new ArrayList(); for (Class clazz : classes) { @@ -251,6 +268,10 @@ public static List fqns(Class... classes) { return fqns; } + /** + * @param classes classes + * @return array + */ @SuppressWarnings("rawtypes") public static String[] resources( Class ... classes) { List resources = new ArrayList<>(); @@ -261,10 +282,20 @@ public static String[] resources( Class ... classes) { } + /** + * @param T + * @param clazz class + * @return content + */ public static String resource(Class clazz) { return "META-INF/" + clazz.getSimpleName() + ".json"; } + /** + * @param T + * @param clazz class + * @return InputStream + */ public static InputStream stream(Class clazz) { return OData2TestUtils.class.getClassLoader().getResourceAsStream(resource(clazz)); } diff --git a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/test/util/Pair.java b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/test/util/Pair.java index b7524208e90..afb25a88a4b 100644 --- a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/test/util/Pair.java +++ b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/test/util/Pair.java @@ -13,6 +13,12 @@ import java.io.Serializable; +/** + * Pair + * + * @param t + * @param u + */ public class Pair implements Serializable { private static final long serialVersionUID = 8719382431393826469L; @@ -25,15 +31,25 @@ private Pair() { this.second = null; } + /** + * @param a a + * @param b b + */ public Pair(T a, U b) { this.first = a; this.second = b; } + /** + * @return T + */ public T getFirst() { return first; } + /** + * @return U + */ public U getSecond() { return second; } @@ -43,10 +59,22 @@ public String toString() { return "[" + first + ", " + second + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } + /** + * @param T + * @param U + * @param a a + * @param b b + * @return Pair + */ public static Pair create(T a, U b) { return new Pair(a, b); } + /** + * @param T + * @param U + * @return Pair + */ @SuppressWarnings("unchecked") public static final Pair nullPair() { return (Pair) NULL_PAIR; diff --git a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/test/util/Triple.java b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/test/util/Triple.java index 2ee35e02ba8..73e604a81b3 100644 --- a/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/test/util/Triple.java +++ b/modules/odata/odata-core-test/src/main/java/org/eclipse/dirigible/engine/odata2/sql/test/util/Triple.java @@ -13,6 +13,13 @@ import java.io.Serializable; +/** + * Triple + * + * @param T + * @param U + * @param V + */ public class Triple implements Serializable { private static final long serialVersionUID = 8719382431393826469L; @@ -20,26 +27,38 @@ public class Triple implements Serializable { private final U second; private final V third; + /** + * @param a a + * @param b b + * @param c c + */ public Triple(T a, U b, V c) { first = a; second = b; third = c; } + /** + * @return T + */ public T getFirst() { return first; } + /** + * @return U + */ public U getSecond() { return second; } + /** + * @return V + */ public V getThird() { return third; } - - @Override public int hashCode() { final int prime = 31; @@ -82,10 +101,25 @@ public String toString() { return "[" + first + ", " + second + ", " + third + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } + /** + * @param T + * @param U + * @param V + * @param a a + * @param b b + * @param c c + * @return Triple + */ public static Triple create(T a, U b, V c) { return new Triple(a, b, c); } + /** + * @param T + * @param U + * @param V + * @return Triple + */ @SuppressWarnings("unchecked") public static final Triple nullTriple() { return (Triple) NULL_TRIPLE; diff --git a/modules/odata/odata-samples-northwind/src/test/java/org/eclipse/dirigible/engine/odata2/sql/ODataSQLProcessorNorthwindTest.java b/modules/odata/odata-samples-northwind/src/test/java/org/eclipse/dirigible/engine/odata2/sql/ODataSQLProcessorNorthwindTest.java index 8fa98b2cd29..9cab14b0752 100644 --- a/modules/odata/odata-samples-northwind/src/test/java/org/eclipse/dirigible/engine/odata2/sql/ODataSQLProcessorNorthwindTest.java +++ b/modules/odata/odata-samples-northwind/src/test/java/org/eclipse/dirigible/engine/odata2/sql/ODataSQLProcessorNorthwindTest.java @@ -72,12 +72,15 @@ public void testProductsResponse() throws Exception { .param("$format", "json") // .executeRequest(GET); String content = IOUtils.toString((InputStream) response.getEntity()); - assertNotNull(content); - System.err.println(content); + assertEquals(loadExpectedData("products-all.json"), content); } private String loadExpectedMetadata() throws IOException { - String metadata = loadExpectedData("metadata.xml"); - return metadata.replaceAll("\n", "").replaceAll("[^\\S\\r]{2,}", ""); + return loadExpectedData("metadata.xml"); + } + + private String loadExpectedData(String fileName) throws IOException { + String data = loadResource(fileName); + return data.replaceAll("\n", "").replaceAll("[^\\S\\r]{2,}", ""); } } \ No newline at end of file diff --git a/modules/odata/odata-samples-northwind/src/test/resources/org/eclipse/dirigible/engine/odata2/sql/products-all.json b/modules/odata/odata-samples-northwind/src/test/resources/org/eclipse/dirigible/engine/odata2/sql/products-all.json new file mode 100644 index 00000000000..4874f6be682 --- /dev/null +++ b/modules/odata/odata-samples-northwind/src/test/resources/org/eclipse/dirigible/engine/odata2/sql/products-all.json @@ -0,0 +1,325 @@ +{ + "d": { + "results": [ + { + "__metadata": { + "id": "http://localhost:8080/api/v1/Products(0)", + "uri": "http://localhost:8080/api/v1/Products(0)", + "type": "org.eclipse.dirigible.engine.odata2.sql.entities.northwind.Product" + }, + "ID": 0, + "Name": "Bread", + "Description": "Whole grain bread", + "ReleaseDate": "\/Date(694216800000)\/", + "DiscontinuedDate": null, + "Rating": 4, + "Price": "2.5", + "Categories": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(0)/Categories" + } + }, + "Supplier": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(0)/Supplier" + } + }, + "ProductDetail": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(0)/ProductDetail" + } + } + }, + { + "__metadata": { + "id": "http://localhost:8080/api/v1/Products(1)", + "uri": "http://localhost:8080/api/v1/Products(1)", + "type": "org.eclipse.dirigible.engine.odata2.sql.entities.northwind.Product" + }, + "ID": 1, + "Name": "Milk", + "Description": "Low fat milk", + "ReleaseDate": "\/Date(812498400000)\/", + "DiscontinuedDate": null, + "Rating": 3, + "Price": "3.5", + "Categories": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(1)/Categories" + } + }, + "Supplier": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(1)/Supplier" + } + }, + "ProductDetail": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(1)/ProductDetail" + } + } + }, + { + "__metadata": { + "id": "http://localhost:8080/api/v1/Products(2)", + "uri": "http://localhost:8080/api/v1/Products(2)", + "type": "org.eclipse.dirigible.engine.odata2.sql.entities.northwind.Product" + }, + "ID": 2, + "Name": "Vint soda", + "Description": "Americana Variety - Mix of 6 flavors", + "ReleaseDate": "\/Date(970347600000)\/", + "DiscontinuedDate": null, + "Rating": 3, + "Price": "20.9", + "Categories": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(2)/Categories" + } + }, + "Supplier": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(2)/Supplier" + } + }, + "ProductDetail": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(2)/ProductDetail" + } + } + }, + { + "__metadata": { + "id": "http://localhost:8080/api/v1/Products(3)", + "uri": "http://localhost:8080/api/v1/Products(3)", + "type": "org.eclipse.dirigible.engine.odata2.sql.entities.northwind.Product" + }, + "ID": 3, + "Name": "Havina Cola", + "Description": "The Original Key Lime Cola", + "ReleaseDate": "\/Date(1128114000000)\/", + "DiscontinuedDate": "\/Date(1159650000000)\/", + "Rating": 3, + "Price": "19.9", + "Categories": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(3)/Categories" + } + }, + "Supplier": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(3)/Supplier" + } + }, + "ProductDetail": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(3)/ProductDetail" + } + } + }, + { + "__metadata": { + "id": "http://localhost:8080/api/v1/Products(4)", + "uri": "http://localhost:8080/api/v1/Products(4)", + "type": "org.eclipse.dirigible.engine.odata2.sql.entities.northwind.Product" + }, + "ID": 4, + "Name": "Fruit Punch", + "Description": "Mango flavor, 8.3 Ounce Cans (Pack of 24)", + "ReleaseDate": "\/Date(1041717600000)\/", + "DiscontinuedDate": null, + "Rating": 3, + "Price": "22.99", + "Categories": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(4)/Categories" + } + }, + "Supplier": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(4)/Supplier" + } + }, + "ProductDetail": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(4)/ProductDetail" + } + } + }, + { + "__metadata": { + "id": "http://localhost:8080/api/v1/Products(5)", + "uri": "http://localhost:8080/api/v1/Products(5)", + "type": "org.eclipse.dirigible.engine.odata2.sql.entities.northwind.Product" + }, + "ID": 5, + "Name": "Cranberry Juice", + "Description": "16-Ounce Plastic Bottles (Pack of 12)", + "ReleaseDate": "\/Date(1154638800000)\/", + "DiscontinuedDate": null, + "Rating": 3, + "Price": "22.8", + "Categories": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(5)/Categories" + } + }, + "Supplier": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(5)/Supplier" + } + }, + "ProductDetail": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(5)/ProductDetail" + } + } + }, + { + "__metadata": { + "id": "http://localhost:8080/api/v1/Products(6)", + "uri": "http://localhost:8080/api/v1/Products(6)", + "type": "org.eclipse.dirigible.engine.odata2.sql.entities.northwind.Product" + }, + "ID": 6, + "Name": "Pink Lemonade", + "Description": "36 Ounce Cans (Pack of 3)", + "ReleaseDate": "\/Date(1162677600000)\/", + "DiscontinuedDate": null, + "Rating": 3, + "Price": "18.8", + "Categories": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(6)/Categories" + } + }, + "Supplier": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(6)/Supplier" + } + }, + "ProductDetail": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(6)/ProductDetail" + } + } + }, + { + "__metadata": { + "id": "http://localhost:8080/api/v1/Products(7)", + "uri": "http://localhost:8080/api/v1/Products(7)", + "type": "org.eclipse.dirigible.engine.odata2.sql.entities.northwind.Product" + }, + "ID": 7, + "Name": "DVD Player", + "Description": "1080P Upconversion DVD Player", + "ReleaseDate": "\/Date(1163541600000)\/", + "DiscontinuedDate": null, + "Rating": 5, + "Price": "35.88", + "Categories": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(7)/Categories" + } + }, + "Supplier": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(7)/Supplier" + } + }, + "ProductDetail": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(7)/ProductDetail" + } + } + }, + { + "__metadata": { + "id": "http://localhost:8080/api/v1/Products(8)", + "uri": "http://localhost:8080/api/v1/Products(8)", + "type": "org.eclipse.dirigible.engine.odata2.sql.entities.northwind.Product" + }, + "ID": 8, + "Name": "LCD HDTV", + "Description": "42 inch 1080p LCD with Built-in Blu-ray Disc Player", + "ReleaseDate": "\/Date(1210194000000)\/", + "DiscontinuedDate": null, + "Rating": 3, + "Price": "1088.8", + "Categories": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(8)/Categories" + } + }, + "Supplier": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(8)/Supplier" + } + }, + "ProductDetail": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(8)/ProductDetail" + } + } + }, + { + "__metadata": { + "id": "http://localhost:8080/api/v1/Products(9)", + "uri": "http://localhost:8080/api/v1/Products(9)", + "type": "org.eclipse.dirigible.engine.odata2.sql.entities.northwind.Product" + }, + "ID": 9, + "Name": "Lemonade", + "Description": "Classic, refreshing lemonade (Single bottle)", + "ReleaseDate": "\/Date(-7200000)\/", + "DiscontinuedDate": null, + "Rating": 7, + "Price": "1.01", + "Categories": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(9)/Categories" + } + }, + "Supplier": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(9)/Supplier" + } + }, + "ProductDetail": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(9)/ProductDetail" + } + } + }, + { + "__metadata": { + "id": "http://localhost:8080/api/v1/Products(10)", + "uri": "http://localhost:8080/api/v1/Products(10)", + "type": "org.eclipse.dirigible.engine.odata2.sql.entities.northwind.Product" + }, + "ID": 10, + "Name": "Coffee", + "Description": "Bulk size can of instant coffee", + "ReleaseDate": "\/Date(410133600000)\/", + "DiscontinuedDate": null, + "Rating": 1, + "Price": "6.99", + "Categories": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(10)/Categories" + } + }, + "Supplier": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(10)/Supplier" + } + }, + "ProductDetail": { + "__deferred": { + "uri": "http://localhost:8080/api/v1/Products(10)/ProductDetail" + } + } + } + ] + } +} \ No newline at end of file