Package com.cumulocity.me.lang

Examples of com.cumulocity.me.lang.Map$Entry


    @Then("I should I get all the audit records$")
    public void shouldGetAllMeasurements() {
        assertThat(collection1.getAuditRecords().size(), is(equalTo(result1.size())));

        Map map = new HashMap();

        Iterator iterator = result1.iterator();
        while (iterator.hasNext()) {
            AuditRecordRepresentation rep = (AuditRecordRepresentation) iterator.next();
            map.put(rep.getId(), rep);
        }

        iterator = collection1.getAuditRecords().iterator();
        while (iterator.hasNext()) {
            AuditRecordRepresentation orig = (AuditRecordRepresentation) map.get(((AuditRecordRepresentation) iterator.next()).getId());
            assertThat(orig, is(notNullValue()));
        }
    }
View Full Code Here


    @Then("I should get back all the external ids")
    public void shouldGetBackAllTheIds() throws SDKException {
        collection1 = (ExternalIDCollectionRepresentation) identity.getExternalIdsOfGlobalId(((ExternalIDRepresentation) input.get(0)).getManagedObject().getId()).get();
        assertEquals(input.size(), collection1.getExternalIds().size());

        Map result = new HashMap();

        for (int index = 0; index < input.size(); index++) {
            result.put(((ExternalIDRepresentation) collection1.getExternalIds().get(index)).getExternalId(), collection1.getExternalIds().get(index));
        }

        for (int index = 0; index < input.size(); index++) {
            ExternalIDRepresentation rep = (ExternalIDRepresentation) result.get(((ExternalIDRepresentation) input.get(index)).getExternalId());
            assertNotNull(rep);
            assertEquals(((ExternalIDRepresentation) input.get(index)).getType(), rep.getType());
            assertEquals(((ExternalIDRepresentation) input.get(index)).getManagedObject().getId().getValue(), rep.getManagedObject().getId().getValue());
        }
View Full Code Here

    public byte[] getData() {
        return data;
    }
   
    private Map readHeaders(HttpConnection connection) throws IOException {
        Map headers = new HashMap();
        String key = null;
        int i = 0;
        while ((key = connection.getHeaderFieldKey(i)) != null) {
            headers.put(key, connection.getHeaderField(i));
            i++;
        }
        return headers;
    }
View Full Code Here

        Date dateFrom = filter.getFromDate();
        Date dateTo = filter.getToDate();
        Class fragmentType = filter.getFragmentType();
        ManagedObjectRepresentation source = filter.getSource();

        Map filterMap = new HashMap();
        if (null != source) {
            filterMap.put(SOURCE, source.getId().getValue());
        }
        if (null != dateFrom) {
            filterMap.put(DATE_FROM, DateUtils.format(dateFrom));
        }
        if (null != dateTo) {
            filterMap.put(DATE_TO, DateUtils.format(dateTo));
        }
        if (null != fragmentType) {
            filterMap.put(FRAGMENT_TYPE, ExtensibilityConverter.classToStringRepresentation(fragmentType));
        }
        if (null != type) {
            filterMap.put(TYPE, type);
        }

        QueryURLBuilder query = new QueryURLBuilder(templateUrlParser, filterMap, getEventApiRepresentation().getURITemplates(),
                OPTIONAL_PARAMETERS);
        String queryUrl = query.build();
View Full Code Here

    public BaseCollectionRepresentation getPage(BaseCollectionRepresentation collectionRepresentation, int pageNumber, int pageSize) {
        if (collectionRepresentation == null || collectionRepresentation.getSelf() == null) {
            throw new SDKException("Unable to determin the Resource URL. ");
        }

        Map params = new HashMap();
        params.put(PAGE_SIZE_KEY, String.valueOf(pageSize < 1 ? DEFAULT_PAGE_SIZE : pageSize));
        params.put(PAGE_NUMBER_KEY, String.valueOf(pageNumber));

        String url = replaceOrAddQueryParam(collectionRepresentation.getSelf(), params);
        return getCollection(url);
    }
View Full Code Here

    private String replaceOrAddQueryParam(String url, Map newParams) {
        String[] urlParts = StringUtils.split(url, "\\?");
        String partOfUrlWithoutQueryParams = urlParts[0];
        String queryParamsString = (urlParts.length == 2) ? urlParts[1] : "";

        Map queryParams = parseQueryParams(queryParamsString);
        queryParams.putAll(newParams);
        return buildUrl(partOfUrlWithoutQueryParams, queryParams);
    }
View Full Code Here

        return builder.toString();
    }

    private Map parseQueryParams(String queryParams) {
        Map result = new HashMap();
        String[] pairs = StringUtils.split(queryParams, "&");
        for (int i = 0; i < pairs.length; i++) {
          String pair = pairs[i];
            String[] items = StringUtils.split(pair, "=");
            if (items.length == 2) {
                result.put(items[0], items[1]);
            }
        }

        return result;
    }
View Full Code Here

        return new OperationCollectionImpl(restConnector, url, pageSize);
    }

    private PagedCollectionResource getOperationsByStatus(OperationStatus status) throws SDKException {
        String urlTemplate = getDeviceControlRepresentation().getOperationsByStatus();
        Map filter = new HashMap();
        filter.put(STATUS, status.toString());
        String url = templateUrlParser.replacePlaceholdersWithParams(urlTemplate, filter);
        return new OperationCollectionImpl(restConnector, url, pageSize);
    }
View Full Code Here

        return new OperationCollectionImpl(restConnector, url, pageSize);
    }

    private PagedCollectionResource getOperationsByAgent(String agentId) throws SDKException {
        String urlTemplate = getDeviceControlRepresentation().getOperationsByAgentId();
        Map filter = new HashMap();
        filter.put(AGENT_ID, agentId);
        String url = templateUrlParser.replacePlaceholdersWithParams(urlTemplate, filter);
        return new OperationCollectionImpl(restConnector, url, pageSize);
    }
View Full Code Here

        return new OperationCollectionImpl(restConnector, url, pageSize);
    }

    private PagedCollectionResource getOperationsByAgentAndStatus(String agentId, OperationStatus status) throws SDKException {
        String urlTemplate = getDeviceControlRepresentation().getOperationsByAgentIdAndStatus();
        Map filter = new HashMap();
        filter.put(AGENT_ID, agentId);
        filter.put(STATUS, status.toString());
        String url = templateUrlParser.replacePlaceholdersWithParams(urlTemplate, filter);
        return new OperationCollectionImpl(restConnector, url, pageSize);
    }
View Full Code Here

TOP

Related Classes of com.cumulocity.me.lang.Map$Entry

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.