Package com.cumulocity.rest.representation

Examples of com.cumulocity.rest.representation.TestCollectionRepresentation


    }

    @Test
    public void shouldGetAndAddPageSizeParamWhenNoOtherParams() throws SDKException {
        // Given
        TestCollectionRepresentation expectedRepresentation = new TestCollectionRepresentation();
        when(restConnector.get(URL + "?pageSize=" + PAGE_SIZE, MEDIA_TYPE, CLAZZ)).thenReturn(expectedRepresentation);

        // When
        TestCollectionRepresentation page = target.get();

        // Then       
        assertThat(page, sameInstance(expectedRepresentation));
    }
View Full Code Here


    @Test
    public void shouldGetAndAddPageSizeParamWhenOtherParamsPresent() throws SDKException {
        // Given
        String myUrlWithOtherParam = URL + "?param=value";
        target = createPagedCollectionResource(restConnector, myUrlWithOtherParam, PAGE_SIZE, MEDIA_TYPE, CLAZZ);
        TestCollectionRepresentation expectedRepresentation = new TestCollectionRepresentation();
        String expectedUrl = myUrlWithOtherParam + "&pageSize=" + PAGE_SIZE;

        when(restConnector.get(argThat(matchesUrl(expectedUrl)), eq(MEDIA_TYPE), eq(CLAZZ))).thenReturn(expectedRepresentation);

        // When
        TestCollectionRepresentation page = target.get();

        // Then       
        assertThat(page, sameInstance(expectedRepresentation));
    }
View Full Code Here

    @Test
    public void shouldGetAndReplaceAlreadyPresentPageSizeParam() throws SDKException {
        // Given
        String myUrlWithOtherParamAndPageSize = URL + "?param1=value1&pageSize=15&param2=value2";
        target = createPagedCollectionResource(restConnector, myUrlWithOtherParamAndPageSize, PAGE_SIZE, MEDIA_TYPE, CLAZZ);
        TestCollectionRepresentation expectedRepresentation = new TestCollectionRepresentation();
        String expectedUrl = URL + "?param1=value1&param2=value2&pageSize=" + PAGE_SIZE;

        when(restConnector.get(argThat(matchesUrl(expectedUrl)), eq(MEDIA_TYPE), eq(CLAZZ))).thenReturn(expectedRepresentation);

        // When
        TestCollectionRepresentation page = target.get();

        // Then       
        assertThat(page, sameInstance(expectedRepresentation));
    }
View Full Code Here

    }

    @Test
    public void shouldGetPageWhenNoParamsPresent() throws SDKException {
        // Given
        TestCollectionRepresentation input = new TestCollectionRepresentation();
        input.setPageStatistics(new PageStatisticsRepresentation(PAGE_SIZE));
        input.setSelf(URL + "/measuremnt/measurments");

        String expectedUrl = input.getSelf() + "?pageSize=" + PAGE_SIZE + "&currentPage=5";
        TestCollectionRepresentation expectedRep = new TestCollectionRepresentation();
        when(restConnector.get(argThat(matchesUrl(expectedUrl)), eq(MEDIA_TYPE), eq(CLAZZ))).thenReturn(expectedRep);

        // When
        TestCollectionRepresentation page = target.getPage(input, 5);

        // Then       
        assertThat(page, sameInstance(expectedRep));
    }
View Full Code Here

    }

    @Test
    public void shouldGetPageWhenWithGivenPageSize() throws SDKException {
        // Given
        TestCollectionRepresentation input = new TestCollectionRepresentation();
        String myUrl = URL + "/measuremnt/measurments";
        input.setSelf(myUrl);

        String expectedUrl = myUrl + "?pageSize=50&currentPage=5";
        TestCollectionRepresentation expectedRep = new TestCollectionRepresentation();
        when(restConnector.get(argThat(matchesUrl(expectedUrl)), eq(MEDIA_TYPE), eq(CLAZZ))).thenReturn(expectedRep);

        // When
        TestCollectionRepresentation page = target.getPage(input, 5, 50);

        // Then
        assertThat(page, sameInstance(expectedRep));
    }
View Full Code Here

    }

    @Test
    public void shouldGetPageWhenOtherParamsAlreadyPresent() throws SDKException {
        // Given
        TestCollectionRepresentation input = new TestCollectionRepresentation();
        input.setPageStatistics(new PageStatisticsRepresentation(PAGE_SIZE));
        input.setSelf(URL + "/measuremnt/measurments?param1=value1");

        String expectedUrl = input.getSelf() + "&pageSize=" + PAGE_SIZE + "&currentPage=5";
        TestCollectionRepresentation expectedRep = new TestCollectionRepresentation();
        when(restConnector.get(argThat(matchesUrl(expectedUrl)), eq(MEDIA_TYPE), eq(CLAZZ))).thenReturn(expectedRep);

        // When
        TestCollectionRepresentation page = target.getPage(input, 5);

        // Then       
        assertThat(page, sameInstance(expectedRep));
    }
View Full Code Here

    }

    @Test
    public void shouldGetPageAndReplaceAlreadyPresentPageSizeAndCurrentPageParams() throws SDKException {
        // Given
        TestCollectionRepresentation input = new TestCollectionRepresentation();
        input.setPageStatistics(new PageStatisticsRepresentation(PAGE_SIZE));
        String myUrl = URL + "/measuremnt/measurments?param1=value1&pageSize=123&currentPage=234";
        input.setSelf(myUrl);

        String expectedUrl = URL + "/measuremnt/measurments?param1=value1" + "&pageSize=" + PAGE_SIZE + "&currentPage=6";
        TestCollectionRepresentation expectedRep = new TestCollectionRepresentation();
        when(restConnector.get(argThat(matchesUrl(expectedUrl)), eq(MEDIA_TYPE), eq(CLAZZ))).thenReturn(expectedRep);

        // When
        TestCollectionRepresentation page = target.getPage(input, 6);

        // Then       
        assertThat(page, sameInstance(expectedRep));
    }
View Full Code Here

    }

    @Test(expected = SDKException.class)
    public void shouldGetPageValidInput() throws SDKException {
        // Given
        TestCollectionRepresentation input = null;

        // When
        target.getPage(input, 5);

        // Then
View Full Code Here

    @Test
    public void shouldGetNextPage() throws SDKException {
        //Given
        String url = "/measuremnt/measurments";
        TestCollectionRepresentation input = new TestCollectionRepresentation();
        input.setNext(url);
        TestCollectionRepresentation expectedResult = new TestCollectionRepresentation();

        when(restConnector.get(url, MEDIA_TYPE, CLAZZ)).thenReturn(expectedResult);

        //when
        TestCollectionRepresentation nextPage = target.getNextPage(input);

        // Then
        assertThat(nextPage, is(expectedResult));
    }
View Full Code Here

    }

    @Test
    public void shouldGetNextPageInvalidInput() throws SDKException {
        // Given
        TestCollectionRepresentation input = new TestCollectionRepresentation();

        // When
        TestCollectionRepresentation nextPage = target.getNextPage(input);

        // Then
        assertNull(nextPage);
    }
View Full Code Here

TOP

Related Classes of com.cumulocity.rest.representation.TestCollectionRepresentation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.