/**
 * Copyright (c) 2014 All Rights Reserved by the SDL Group.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.sdl.odata.parser;

import com.sdl.odata.api.ODataException;
import com.sdl.odata.api.parser.RelativeUri;
import com.sdl.odata.api.parser.ResourcePathUri;
import org.junit.Test;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

/**
 * Parser Order Test.
 *
 */
public class ParserOrderTest extends ParserTestSuite {

    @Test
    public void testFirstCustomer() throws ODataException {
        uri = parser.parseUri(SERVICE_ROOT + "Customers(0)", model);
        assertNotNull(uri);
        RelativeUri relative = uri.relativeUri();
        assertNotNull(relative);
        assertTrue(relative instanceof ResourcePathUri);
        assertTrue(relative.toString().contains("Customers"));
        assertTrue(relative.toString().contains("NumberLiteral(0)"));
    }

    @Test
    public void testSecondOrder() throws ODataException {
        uri = parser.parseUri(SERVICE_ROOT + "Orders(1)", model);
        RelativeUri relative = uri.relativeUri();
        assertNotNull(relative);
        assertTrue(relative.toString().contains("Orders"));
        assertTrue(relative.toString().contains("NumberLiteral(1)"));
        assertNotNull(uri);
    }

    @Test
    public void testProductsNumberLiteral() throws ODataException {
        // Notice , that i starts from -1 that is also valid
        for (int i = -1; i < 9; i++) {
            uri = parser.parseUri(SERVICE_ROOT + "Products(" + i + ")", model);
            RelativeUri relative = uri.relativeUri();
            assertNotNull(relative);
            assertTrue(relative.toString().contains("Products"));
            assertTrue(relative.toString().contains("NumberLiteral(" + i + ")"));
        }
    }

}

@@ -2331,10 +2331,1152 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testFirstCustomerProducts() throws ODataException %7B%0A        uri = parser.parseUri(SERVICE_ROOT + %22Customers(0)/Orders%22, model);%0A        assertNotNull(uri);%0A        RelativeUri relative = uri.relativeUri();%0A        assertNotNull(relative);%0A        assertTrue(relative instanceof ResourcePathUri);%0A        assertTrue(relative.toString().contains(%22Customers%22));%0A        assertTrue(relative.toString().contains(%22NumberLiteral(0)%22));%0A        assertTrue(relative.toString().contains(%22Orders%22));%0A    %7D%0A%0A    @Test%0A    public void testFirstCustomerFirstProductFirstOrderLine() throws ODataException %7B%0A        uri = parser.parseUri(SERVICE_ROOT + %22Customers(0)/Orders(0)/orderLines(0)%22, model);%0A        assertNotNull(uri);%0A        RelativeUri relative = uri.relativeUri();%0A        assertNotNull(relative);%0A        assertTrue(relative instanceof ResourcePathUri);%0A        assertTrue(relative.toString().contains(%22Customers%22));%0A        assertTrue(relative.toString().contains(%22NumberLiteral(0)%22));%0A        assertTrue(relative.toString().contains(%22Orders%22));%0A        assertTrue(relative.toString().contains(%22orderLines%22));%0A    %7D%0A
 %7D%0A

Enhance parser tests with nested entities