Package org.auraframework.util.json

Examples of org.auraframework.util.json.JsonReader


    @SuppressWarnings("unchecked")
    private Map<String,Object> validateEmptyActionSerialization(String serialized, Set<String> ignore,
        List<String> actionNameList) {
      int actionNumber = actionNameList.size();
        Set<String> extras = Sets.newHashSet();
        Map<String, Object> json = (Map<String, Object>) new JsonReader().read(serialized);
        List<Object> actions = (List<Object>) json.get("actions");
        assertTrue(actions != null);
        assertTrue("expected "+actionNumber+" action, but get "+actions.size(), actions.size() == actionNumber);
        for(int i=0;i<actionNumber;i++) {
            Map<String, Object> action = (Map<String, Object>) actions.get(i);
View Full Code Here


            return;
        }

        if (!errors.isEmpty()) {
            @SuppressWarnings("unchecked")
            List<Map<String, Object>> errorsList = (List<Map<String, Object>>) new JsonReader().read(errors);
            StringBuffer errorMessage = new StringBuffer();
            for (Map<String, Object> error : errorsList) {
                errorMessage.append(error.get("message") + "\n");
            }
            Assert.fail(errorMessage.toString());
View Full Code Here

                    AuraTextUtil.escapeForJavascriptString(caseDef.getName()),
                    AuraTextUtil.escapeForJavascriptString(suite.getCode())));

            if (ret != null && !"null".equals(ret)) {
                @SuppressWarnings("unchecked")
                Map<String, Object> e = (Map<String, Object>) new JsonReader()
                        .read(ret);
                fail((String) e.get("message"));
            }
            // Actions run on servers need special handling because their call
            // back methods are called asynchronously.
View Full Code Here

        resourceUrl = URLDecoder.decode(resourceUrl, "UTF-8");
        assertTrue(resourceUrl.startsWith("/l/"));
        assertTrue(resourceUrl.endsWith(suffix));
        resourceUrl = resourceUrl.substring("/l/".length(), resourceUrl.length() - suffix.length());
        @SuppressWarnings("unchecked")
        Map<String, Object> configMap = (Map<String, Object>) new JsonReader().read(resourceUrl);
        assertEquals(desc.getDescriptorName(), configMap.get("app"));
    }
View Full Code Here

    }
   
    @SuppressWarnings("unchecked")
    private void verifyStyleDefSerialization(DefDescriptor<StyleDef> styleDesc, Boolean expectCode)throws Exception{
        String serialized = Json.serialize(styleDesc.getDef());
        Object o = new JsonReader().read(serialized);
        assertTrue(o instanceof Map);
        Map<String, Object> outerMap = (Map<String, Object>) o;
        assertEquals(styleDesc.toString(), outerMap.get("descriptor"));
        assertEquals(styleDesc.getNamespace() + AuraTextUtil.initCap(styleDesc.getName()), outerMap.get("className"));
        if(expectCode){
View Full Code Here

                String.format(
                        baseComponentTag,
                        "",
                        "<aura:attribute name='default' type='String' default='innie'/><aura:attribute name='both' type='String' default='outie' serializeTo='BOTH'/><aura:attribute name='server' type='String' default='lint' serializeTo='SERVER'/><aura:attribute name='none' type='String' default='holy' serializeTo='NONE'/>"));
        Component cmp = Aura.getInstanceService().getInstance(desc);
        Map<?, ?> attSet = (Map<?, ?>) new JsonReader().read(toJson(cmp.getAttributes()));
        Map<?, ?> attSetValues = (Map<?, ?>) ((Map<?, ?>) attSet.get("value")).get("values");
        assertEquals(2, attSetValues.size());
        assertEquals("innie", attSetValues.get("default"));
        assertEquals("outie", attSetValues.get("both"));

        // set has no attributes with serializeTo == BOTH
        desc = addSourceAutoCleanup(
                ComponentDef.class,
                String.format(
                        baseComponentTag,
                        "",
                        "<aura:attribute name='server' type='String' default='lint' serializeTo='SERVER'/><aura:attribute name='none' type='String' default='holy' serializeTo='NONE'/>"));
        cmp = Aura.getInstanceService().getInstance(desc);
        attSet = (Map<?, ?>) new JsonReader().read(toJson(cmp.getAttributes()));
        attSetValues = (Map<?, ?>) ((Map<?, ?>) attSet.get("value")).get("values");
        assertEquals(0, attSetValues.size());
    }
View Full Code Here

       
        Map<String, Object> report = null;
       
        try {
            BufferedReader reader = req.getReader();
            report = (Map<String, Object>)new JsonReader().read(reader);
        } catch (Exception e) {
            /* TODO: report an error*/
        }

        // make sure we actually received a csp-report
View Full Code Here

            // handle transaction beacon JSON data
            // FIXME: this should be an action.
            //
            String beaconData = beaconParam.get(request);
            if (!"undefined".equals(beaconData) && !AuraTextUtil.isNullEmptyOrWhitespace(beaconData)) {
                loggingService.setValue(LoggingService.BEACON_DATA, new JsonReader().read(beaconData));
            }


            String fwUID = Aura.getConfigAdapter().getAuraFrameworkNonce();
            if (!fwUID.equals(context.getFrameworkUID())) {
View Full Code Here

    @SuppressWarnings("unchecked")
    private Map<String, Object> getConfigMap(HttpServletRequest request) {
        Map<String, Object> configMap = null;
        String config = contextConfig.get(request);
        if (!AuraTextUtil.isNullEmptyOrWhitespace(config)) {
            configMap = (Map<String, Object>) new JsonReader().read(config);
        }
        return configMap;
    }
View Full Code Here

    public void testJsonSerialization() {
        ValidationError error = new ValidationError("tool", "/file/name", 11, 3, "message", "evidence",
                Level.Error, "rule");
        String json = Json.serialize(error);
        @SuppressWarnings("unchecked")
        ValidationError dError = ValidationError.deserialize((Map<String, ?>) new JsonReader().read(json));
        assertEquals(error.toCommonFormat(), dError.toCommonFormat());
    }
View Full Code Here

TOP

Related Classes of org.auraframework.util.json.JsonReader

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.