Examples of BitWorkingUriTemplateProcessor


Examples of org.apache.wink.common.internal.uritemplate.BitWorkingUriTemplateProcessor

            .expand(hashMap));
    }

    public void testJoinOperator() {
        UriTemplateProcessor template =
            new BitWorkingUriTemplateProcessor("people%3F{-join|&|var1,var2}");
        String[][] allNull = { {"var1", null}, {"var2", null}};
        String[][] firstEmpty = { {"var1", ""}, {"var2", null}};
        String[][] john = { {"var1", "john"}, {"var2", null}};
        String[][] allDefined = { {"var1", "mary"}, {"var2", "kate"}};

        assertMatchTemplate(template, "people%3F/", allNull);
        assertMatchTemplate(template, "people%3F", allNull);
        assertMatchTemplate(template, "people%3Fvar1", null);
        assertMatchTemplate(template, "people%3Fvar1&", null);
        assertMatchTemplate(template, "people%3Fvar1=", firstEmpty);
        assertMatchTemplate(template, "people%3Fvar1=john", john);
        assertMatchTemplate(template, "people%3Fvar1=mary&var2=kate", allDefined);
        assertMatchTemplate(template, "people%3Fvar2=kate&var1=mary", allDefined);
        assertMatchTemplate(template, "people%3Fvar3=jin", null);

        HashMap<String, Object> hashMap = new HashMap<String, Object>();
        hashMap.put("var1", "");
        assertEquals("instantiate template", "people%3Fvar1=", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var1", "jay");
        assertEquals("instantiate template", "people%3Fvar1=jay", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var2", "joe");
        assertEquals("instantiate template", "people%3Fvar2=joe", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var1", "mary");
        hashMap.put("var2", "kate");
        assertEquals("instantiate template", "people%3Fvar1=mary&var2=kate", template
            .expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var3", "joe");
        assertEquals("instantiate template", "people%3F", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        assertEquals("instantiate template", "people%3F", template.expand(hashMap));

        try {
            hashMap = new HashMap<String, Object>();
            hashMap.put("var1", new String[] {"joe", "max"});
            template.expand(hashMap);
            fail("variable must not be a list");
        } catch (IllegalArgumentException expected) {
        }

    }
View Full Code Here

Examples of org.apache.wink.common.internal.uritemplate.BitWorkingUriTemplateProcessor

    }

    public void testNegOperator() {
        UriTemplateProcessor template =
            new BitWorkingUriTemplateProcessor("artifacts{-neg|;|var1,var2}");
        String[][] empty = {};

        assertMatchTemplate(template, "artifact/", null);
        assertMatchTemplate(template, "artifacts", empty);
        assertMatchTemplate(template, "artifacts;", empty);
        assertMatchTemplate(template, "artifacts;;", null);

        HashMap<String, Object> hashMap = new HashMap<String, Object>();
        hashMap.put("var1", (String)null);
        assertEquals("instantiate template", "artifacts", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var2", (String)null);
        assertEquals("instantiate template", "artifacts", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var1", (String)null);
        hashMap.put("var2", (String)null);
        assertEquals("instantiate template", "artifacts", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var1", "");
        assertEquals("instantiate template", "artifacts", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var2", "");
        assertEquals("instantiate template", "artifacts", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var1", "");
        hashMap.put("var2", "");
        assertEquals("instantiate template", "artifacts", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        assertEquals("instantiate template", "artifacts;", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var1", "somevalue");
        assertEquals("instantiate template", "artifacts", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var2", "somevalue");
        assertEquals("instantiate template", "artifacts", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var2", new String[] {});
        assertEquals("instantiate template", "artifacts;", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var2", new String[] {null});
        assertEquals("instantiate template", "artifacts", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var2", new String[] {""});
        assertEquals("instantiate template", "artifacts", template.expand(hashMap));
        hashMap = new HashMap<String, Object>();
        hashMap.put("var2", new String[] {"a", "b"});
        assertEquals("instantiate template", "artifacts", template.expand(hashMap));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.