Package com.cumulocity.me.rest.representation.inventory

Examples of com.cumulocity.me.rest.representation.inventory.ManagedObjectCollectionRepresentation


    ManagedObjectCollectionRepresentationConverter converter = new ManagedObjectCollectionRepresentationConverter();

    @Test
    public void shouldConvertToJson() throws Exception {
        ManagedObjectCollectionRepresentation representation = new ManagedObjectCollectionRepresentation();
        representation.setManagedObjects(getListOfManagedObjects());
        JSONObject expectedJSON = aJSONObject().withProperty(PROP_MANAGED_OBJECTS, getJsonListManagedObjects()).build();

        JSONObject outputJSON = toJson(representation);

        assertThat(outputJSON.toString()).isEqualTo(expectedJSON.toString());
View Full Code Here


    @Test
    public void shouldConvertFromJson() throws Exception {
        JSONObject json = aJSONObject().withProperty(PROP_MANAGED_OBJECTS, getJsonListManagedObjects()).build();

        ManagedObjectCollectionRepresentation representation = fromJson(json);

        assertThat(representation).isNotNull();
        assertThat(representation.getManagedObjects()).isNotNull();
        assertThat(representation.getManagedObjects().size()).isEqualTo(getListOfManagedObjects().size());
    }
View Full Code Here

    }

    @Test
    public void getAllWhenNoManagedObjectPresent() throws Exception {
        // When
        ManagedObjectCollectionRepresentation mos = (ManagedObjectCollectionRepresentation) inventory.getManagedObjects().get();

        // Then
        assertThat(mos.getManagedObjects()).isNotNull();
        assertThat(mos.getManagedObjects().isEmpty()).isTrue();
    }
View Full Code Here

        // When
        inventory.create(rep1);
        inventory.create(rep2);

        // Then
        ManagedObjectCollectionRepresentation mos = (ManagedObjectCollectionRepresentation) inventory.getManagedObjects().get();
        assertThat(mos.getManagedObjects().size()).isEqualTo(2);
    }
View Full Code Here

        inventory.create(aSampleMo().withType("typeA").withName("A2").build());
        inventory.create(aSampleMo().withType("typeB").withName("B").build());

        // When
        InventoryFilter filterA = new InventoryFilter().byType("typeA");
        ManagedObjectCollectionRepresentation typeAMos = (ManagedObjectCollectionRepresentation) inventory.getManagedObjectsByFilter(filterA).get();

        // Then
        assertThat(typeAMos.getManagedObjects().size()).isEqualTo(2);

        // When
        InventoryFilter filterB = new InventoryFilter().byType("typeB");
        ManagedObjectCollectionRepresentation typeBMos = (ManagedObjectCollectionRepresentation) inventory.getManagedObjectsByFilter(filterB).get();

        // Then
        assertThat(typeBMos.getManagedObjects().size()).isEqualTo(1);
    }
View Full Code Here

        // When
        List gidsList = new ArrayList();
        gidsList.add(mo3.getId());
        gidsList.add(mo1.getId());
        ManagedObjectCollectionRepresentation moCollection = (ManagedObjectCollectionRepresentation) inventory.getManagedObjectsByListOfIds(gidsList).get();

        // Then
        List mos = moCollection.getManagedObjects();
        assertThat(mos.size()).isEqualTo(2);
        assertThat(((ManagedObjectRepresentation) mos.get(0)).getName()).isEqualTo("MO3");
        assertThat(((ManagedObjectRepresentation) mos.get(1)).getName()).isEqualTo("MO1");

    }
View Full Code Here

        inventory.create(aSampleMo().withName("MO1").with(new Coordinate()).build());
        inventory.create(aSampleMo().withName("MO2").with(new SecondFragment()).build());

        // When
        InventoryFilter filter = new InventoryFilter().byFragmentType(Coordinate.class);
        ManagedObjectCollectionRepresentation coordinates = (ManagedObjectCollectionRepresentation) inventory.getManagedObjectsByFilter(filter).get();

        // Then
        assertThat(coordinates.getManagedObjects().size()).isEqualTo(1);
    }
View Full Code Here

        for (int i = 0; i < numOfMos; i++) {
            inventory.create(aSampleMo().withName("MO" + i).with(new Coordinate()).build());
        }

        // When
        ManagedObjectCollectionRepresentation mos = (ManagedObjectCollectionRepresentation) inventory.getManagedObjects().get();

        // Then
        assertThat(mos.getPageStatistics().getTotalPages()).isEqualTo(4);

        // When
        ManagedObjectCollectionRepresentation secondPage = (ManagedObjectCollectionRepresentation) inventory.getManagedObjects().getPage(mos, 2);

        // Then
        assertThat(secondPage.getPageStatistics().getCurrentPage()).isEqualTo(2);

        // When
        ManagedObjectCollectionRepresentation thirdPage = (ManagedObjectCollectionRepresentation) inventory.getManagedObjects().getNextPage(secondPage);

        // Then
        assertThat(thirdPage.getPageStatistics().getCurrentPage()).isEqualTo(3);

        // When
        ManagedObjectCollectionRepresentation firstPage = (ManagedObjectCollectionRepresentation) inventory.getManagedObjects().getPreviousPage(secondPage);
        assertThat(firstPage.getPageStatistics().getCurrentPage()).isEqualTo(1);
    }
View Full Code Here

TOP

Related Classes of com.cumulocity.me.rest.representation.inventory.ManagedObjectCollectionRepresentation

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.