/** * Adds a form data entry to this request. * * @param key The form data key. * @param value The form data value. * <br>The value is converted to a simple string using {@link Object#toString()}. * @return This object (for method chaining). */ public MockServletRequest formData(String key, Object value) { if (formDataMap == null) formDataMap = new LinkedHashMap<>(); String s = asString(value); String[] existing = formDataMap.get(key); if (existing == null) existing = new String[]{s}; else existing = new AList<>().appendAll(Arrays.asList(existing)).append(s).toArray(new String[0]); formDataMap.put(key, existing); return this; }
/** * Adds an entry to this list. * * @param t The entry to add to this list. * @return This object (for method chaining). */ public AList<T> append(T t) { add(t); return this; }
AList<String> notAllowed = new AList<>(); boolean invalidFormat = false; switch (type) { case STRING: { notAllowed.appendIf(properties != null, "properties"); notAllowed.appendIf(additionalProperties != null, "additionalProperties"); notAllowed.appendIf(exclusiveMaximum, "exclusiveMaximum"); notAllowed.appendIf(exclusiveMinimum, "exclusiveMinimum"); notAllowed.appendIf(uniqueItems, "uniqueItems"); notAllowed.appendIf(collectionFormat != CollectionFormat.NO_COLLECTION_FORMAT, "collectionFormat"); notAllowed.appendIf(items != null, "items"); notAllowed.appendIf(maximum != null, "maximum"); notAllowed.appendIf(minimum != null, "minimum"); notAllowed.appendIf(multipleOf != null, "multipleOf"); notAllowed.appendIf(maxItems != null, "maxItems"); notAllowed.appendIf(minItems != null, "minItems"); notAllowed.appendIf(minProperties != null, "minProperties"); invalidFormat = ! format.isOneOf(Format.BYTE, Format.BINARY, Format.BINARY_SPACED, Format.DATE, Format.DATE_TIME, Format.PASSWORD, Format.UON, Format.NO_FORMAT); break; notAllowed.appendIf(properties != null, "properties"); notAllowed.appendIf(additionalProperties != null, "additionalProperties"); notAllowed.appendIf(exclusiveMaximum, "exclusiveMaximum"); notAllowed.appendIf(exclusiveMinimum, "exclusiveMinimum"); notAllowed.appendIf(pattern != null, "pattern"); notAllowed.appendIf(maximum != null, "maximum"); notAllowed.appendIf(minimum != null, "minimum"); notAllowed.appendIf(multipleOf != null, "multipleOf"); notAllowed.appendIf(maxLength != null, "maxLength");
PropertyStoreBuilder b = PropertyStore.create(); PropertyStore ps = null; b.set("A.f1.lc", new AList<Class<?>>().appendAll(String.class, Integer.class, null)); b.set("A.f2.lc", new AList<>().appendAll(String.class, Integer.class, null)); b.set("A.f3.lc", null); ps = b.build(); b.set("A.f1.lc/add", AList.<Class<?>>create(Integer.class, String.class)); b.set("A.f1.lc/add", new AList<Class<?>>().appendAll(Map.class)); b.addTo("A.f1.lc", new AList<Class<?>>().appendAll(List.class)); assertObjectEquals("{A:{'f1.lc':['java.util.List','java.util.Map','java.lang.Integer','java.lang.String']}}", b.build()); b.set("A.f1.lc/remove", new AList<Class<?>>().appendAll(Integer.class, String.class)); b.removeFrom("A.f1.lc", new AList<Class<?>>().appendAll()); b.removeFrom("A.f1.lc", new AList<Class<?>>().appendAll(List.class)); assertObjectEquals("{A:{'f1.lc':['java.util.Map']}}", b.build()); b.set("A.f1.lc/add", new AList<>().appendAll(Integer.class, String.class)); b.set("A.f1.lc/add", new AList<>().appendAll(Map.class)); b.addTo("A.f1.lc", new AList<>().appendAll(List.class)); assertObjectEquals("{A:{'f1.lc':['java.util.List','java.util.Map','java.lang.Integer','java.lang.String']}}", b.build()); b.set("A.f1.lc/remove", new AList<>().appendAll(Integer.class, String.class)); b.set("A.f1.lc/remove", new AList<>().appendAll()); b.removeFrom("A.f1.lc", new AList<>().appendAll(List.class)); assertObjectEquals("{A:{'f1.lc':['java.util.Map']}}", b.build());
@Test public void i04a_noSchemaTests_Float() throws Exception { HttpPartSerializer s = OpenApiSerializer.DEFAULT; for (Float v : AList.create(new Float(1f), Float.MAX_VALUE, Float.MIN_VALUE)) assertEquals(valueOf(v), s.serialize((HttpPartSchema)null, v)); }
/** * Adds multiple entries to this list. * * @param t The entries to add to this list. * @return This object (for method chaining). */ public AList<T> appendAll(T...t) { addAll(Arrays.asList(t)); return this; }
AList<String> notAllowed = new AList<>(); boolean invalidFormat = false; switch (type) { case STRING: { notAllowed.appendIf(properties != null, "properties"); notAllowed.appendIf(additionalProperties != null, "additionalProperties"); notAllowed.appendIf(exclusiveMaximum, "exclusiveMaximum"); notAllowed.appendIf(exclusiveMinimum, "exclusiveMinimum"); notAllowed.appendIf(uniqueItems, "uniqueItems"); notAllowed.appendIf(collectionFormat != CollectionFormat.NO_COLLECTION_FORMAT, "collectionFormat"); notAllowed.appendIf(items != null, "items"); notAllowed.appendIf(maximum != null, "maximum"); notAllowed.appendIf(minimum != null, "minimum"); notAllowed.appendIf(multipleOf != null, "multipleOf"); notAllowed.appendIf(maxItems != null, "maxItems"); notAllowed.appendIf(minItems != null, "minItems"); notAllowed.appendIf(minProperties != null, "minProperties"); invalidFormat = ! format.isOneOf(Format.BYTE, Format.BINARY, Format.BINARY_SPACED, Format.DATE, Format.DATE_TIME, Format.PASSWORD, Format.UON, Format.NO_FORMAT); break; notAllowed.appendIf(properties != null, "properties"); notAllowed.appendIf(additionalProperties != null, "additionalProperties"); notAllowed.appendIf(exclusiveMaximum, "exclusiveMaximum"); notAllowed.appendIf(exclusiveMinimum, "exclusiveMinimum"); notAllowed.appendIf(pattern != null, "pattern"); notAllowed.appendIf(maximum != null, "maximum"); notAllowed.appendIf(minimum != null, "minimum"); notAllowed.appendIf(multipleOf != null, "multipleOf"); notAllowed.appendIf(maxLength != null, "maxLength");
@Test public void i05a_noSchemaTests_Double() throws Exception { HttpPartSerializer s = OpenApiSerializer.DEFAULT; for (Double v : AList.create(new Double(1d), Double.MAX_VALUE, Double.MIN_VALUE)) assertEquals(valueOf(v), s.serialize((HttpPartSchema)null, v)); }
/** * Adds multiple entries to this list. * * @param t The entries to add to this list. * @return This object (for method chaining). */ public AList<T> appendAll(T...t) { addAll(Arrays.asList(t)); return this; }
/** * Adds a query data entry to this request. * * @param key The query key. * @param value The query value. * <br>The value is converted to a simple string using {@link Object#toString()}. * @return This object (for method chaining). */ public MockServletRequest query(String key, Object value) { if (queryData == null) queryData = new LinkedHashMap<>(); String s = asString(value); String[] existing = queryData.get(key); if (existing == null) existing = new String[]{s}; else existing = new AList<>().appendAll(Arrays.asList(existing)).append(s).toArray(new String[0]); queryData.put(key, existing); return this; }
AList<String> notAllowed = new AList<>(); boolean invalidFormat = false; switch (type) { case STRING: { notAllowed.appendIf(properties != null, "properties"); notAllowed.appendIf(additionalProperties != null, "additionalProperties"); notAllowed.appendIf(exclusiveMaximum, "exclusiveMaximum"); notAllowed.appendIf(exclusiveMinimum, "exclusiveMinimum"); notAllowed.appendIf(uniqueItems, "uniqueItems"); notAllowed.appendIf(collectionFormat != CollectionFormat.NO_COLLECTION_FORMAT, "collectionFormat"); notAllowed.appendIf(items != null, "items"); notAllowed.appendIf(maximum != null, "maximum"); notAllowed.appendIf(minimum != null, "minimum"); notAllowed.appendIf(multipleOf != null, "multipleOf"); notAllowed.appendIf(maxItems != null, "maxItems"); notAllowed.appendIf(minItems != null, "minItems"); notAllowed.appendIf(minProperties != null, "minProperties"); invalidFormat = ! format.isOneOf(Format.BYTE, Format.BINARY, Format.BINARY_SPACED, Format.DATE, Format.DATE_TIME, Format.PASSWORD, Format.UON, Format.NO_FORMAT); break; notAllowed.appendIf(properties != null, "properties"); notAllowed.appendIf(additionalProperties != null, "additionalProperties"); notAllowed.appendIf(exclusiveMaximum, "exclusiveMaximum"); notAllowed.appendIf(exclusiveMinimum, "exclusiveMinimum"); notAllowed.appendIf(pattern != null, "pattern"); notAllowed.appendIf(maximum != null, "maximum"); notAllowed.appendIf(minimum != null, "minimum"); notAllowed.appendIf(multipleOf != null, "multipleOf"); notAllowed.appendIf(maxLength != null, "maxLength");
@RestMethod @Response public List<Integer> g03() { return AList.create(1,2); } @RestMethod
/** * Adds an entry to this list. * * @param t The entry to add to this list. * @return This object (for method chaining). */ public AList<T> append(T t) { add(t); return this; }
/** * Adds multiple entries to this list. * * @param t The entries to add to this list. * @return This object (for method chaining). */ public AList<T> appendAll(T...t) { addAll(Arrays.asList(t)); return this; }