Package com.cumulocity.rest.representation.inventory

Examples of com.cumulocity.rest.representation.inventory.ManagedObjectRepresentation


        return restConnector.get(path, InventoryMediaType.MANAGED_OBJECT_REFERENCE, ManagedObjectReferenceRepresentation.class);
    }

    @Override
    public void deleteChildAsset(GId assetId) throws SDKException {
        ManagedObjectRepresentation managedObjectRepresentation = get();
        String path = createChildAssetPath(managedObjectRepresentation) + "/" + assetId.getValue();
        restConnector.delete(path);
    }
View Full Code Here


    @Before
    public void setUp() throws Exception {
        inventory = platform.getInventoryApi();

        ManagedObjectRepresentation parentRep = inventory.create(aSampleMo().withName("parentRep").build());
        parentMo = inventory.getManagedObject(parentRep.getId());
    }
View Full Code Here

    private void addingSameItemTwiceHasNoEffect(ChildAdder childAdder, ChildrenQuery childrenQuery)
            throws SDKException {

        // Given
        ManagedObjectRepresentation ch1 = inventory.create(aSampleMo().build());
        ManagedObjectRepresentation ch2 = inventory.create(aSampleMo().build());
        ManagedObjectReferenceRepresentation childRef1 = createChildRef(ch1);
        ManagedObjectReferenceRepresentation childRef2 = createChildRef(ch2);

        // When
        childAdder.addChild(childRef1);
        childAdder.addChild(childRef2);
        childAdder.addChild(childRef1);

        // Then
        List<GId> childIds = getIdsOfChildren(childrenQuery);
        assertThat(childIds, is(asList(ch1.getId(), ch2.getId())));
    }
View Full Code Here

    }

    private List<GId> addChildrenToParent(ChildAdder childrenAdder) throws SDKException {
        List<GId> creationOrder = new LinkedList<GId>();
        for (int i = 1; i <= 20; i++) {
            ManagedObjectRepresentation child = inventory.create(aSampleMo().build());
            creationOrder.add(child.getId());
            ManagedObjectReferenceRepresentation childRef = createChildRef(child);

            childrenAdder.addChild(childRef);
        }
        return creationOrder;
View Full Code Here

        //        And I add child devices as per the following:
        //        | parent | child |
        //        | 0      | 1     |
        //        | 2      | 3     |

        ManagedObjectRepresentation agent = aSampleMo().withName("Agent").withType("com.type").with(new Agent()).build();
        ManagedObjectRepresentation device = aSampleMo().withName("Device").withType("com.type").build();
        ManagedObjectRepresentation agent2 = aSampleMo().withName("Agent2").withType("com.type").with(new Agent()).build();
        ManagedObjectRepresentation device2 = aSampleMo().withName("Device2").withType("com.type").build();

        inventoryApi = platform.getInventoryApi();

        agent = inventoryApi.create(agent);
        device = inventoryApi.create(device);
View Full Code Here

    }

    @Test
    public void shouldPostRepresentationSupportingId() throws Exception {
        // Given
        ManagedObjectRepresentation representation = new ManagedObjectRepresentation();
        returnResponseWhenPosting(representation);
        ManagedObjectRepresentation outputRepresentation = new ManagedObjectRepresentation();
        when(parser.parse(response, 201, ManagedObjectRepresentation.class)).thenReturn(outputRepresentation);

        // When
        ManagedObjectRepresentation result = restConnector.post(PATH, mediaType, representation);

        // Then
        assertThat(result, sameInstance(outputRepresentation));
    }
View Full Code Here

    @Test
    public void shouldPostRepresentationSupportingIdWithNoResponseBody() throws Exception {
        // Given
        clientParameters.setRequireResponseBody(false);

        ManagedObjectRepresentation representation = new ManagedObjectRepresentation();
        returnResponseWhenPosting(representation);
        when(parser.parse(response, 201, ManagedObjectRepresentation.class)).thenReturn(null);
        when(response.getLocation()).thenReturn(new URI("http://URI"));
        when(parser.parseIdFromLocation(response)).thenReturn(new GId("mo_id"));

        // When
        ManagedObjectRepresentation result = restConnector.post(PATH, mediaType, representation);

        // Then
        verify(typeBuilder, never()).accept(any(MediaType.class));
        assertThat(result, sameInstance(representation));
        assertThat(result.getId(), is(new GId("mo_id")));
    }
View Full Code Here

    @Test
    public void shouldPostRepresentationSupportingIdWithNoResponseBodyAndNoLocation() throws Exception {
        // Given
        clientParameters.setRequireResponseBody(false);

        ManagedObjectRepresentation representation = new ManagedObjectRepresentation();
        returnResponseWhenPosting(representation);
        when(parser.parse(response, 201, ManagedObjectRepresentation.class)).thenReturn(null);
        when(response.getLocation()).thenReturn(null);

        // When
        ManagedObjectRepresentation result = restConnector.post(PATH, mediaType, representation);

        // Then
        verify(typeBuilder, never()).accept(any(MediaType.class));
        assertThat(result, sameInstance(representation));
        assertThat(result.getId(), nullValue());
    }
View Full Code Here

    }

    @Test
    public void shouldPutRepresentationSupportingId() throws Exception {
        // Given
        ManagedObjectRepresentation representation = new ManagedObjectRepresentation();
        returnResponseWhenPut(representation);
        ManagedObjectRepresentation outputRepresentation = new ManagedObjectRepresentation();
        when(parser.parse(response, 200, ManagedObjectRepresentation.class)).thenReturn(outputRepresentation);

        // When
        ManagedObjectRepresentation result = restConnector.put(PATH, mediaType, representation);

        // Then
        assertThat(result, sameInstance(outputRepresentation));
    }
View Full Code Here

    @Test
    public void shouldPutRepresentationSupportingIdWithNoResponseBody() throws Exception {
        // Given
        clientParameters.setRequireResponseBody(false);

        ManagedObjectRepresentation representation = new ManagedObjectRepresentation();
        returnResponseWhenPut(representation);
        when(parser.parse(response, 200, ManagedObjectRepresentation.class)).thenReturn(null);
        when(response.getLocation()).thenReturn(new URI("http://URI"));
        when(parser.parseIdFromLocation(response)).thenReturn(new GId("mo_id"));

        // When
        ManagedObjectRepresentation result = restConnector.put(PATH, mediaType, representation);

        // Then
        verify(typeBuilder, never()).accept(any(MediaType.class));
        assertThat(result, sameInstance(representation));
        assertThat(result.getId(), is(new GId("mo_id")));
    }
View Full Code Here

TOP

Related Classes of com.cumulocity.rest.representation.inventory.ManagedObjectRepresentation

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.