public static List<Suite> readSuites(File file) throws IOException { requireNonNull(file, "file is null"); checkArgument(file.canRead(), "Cannot read file: %s", file); byte[] json = Files.readAllBytes(file.toPath()); Map<String, OptionsJson> options = mapJsonCodec(String.class, OptionsJson.class).fromJson(json); ImmutableList.Builder<Suite> runOptions = ImmutableList.builder(); for (Entry<String, OptionsJson> entry : options.entrySet()) { runOptions.add(entry.getValue().toSuite(entry.getKey())); } return runOptions.build(); }
public static List<Suite> readSuites(File file) throws IOException { requireNonNull(file, "file is null"); checkArgument(file.canRead(), "Cannot read file: %s", file); byte[] json = Files.readAllBytes(file.toPath()); Map<String, OptionsJson> options = mapJsonCodec(String.class, OptionsJson.class).fromJson(json); ImmutableList.Builder<Suite> runOptions = ImmutableList.builder(); for (Entry<String, OptionsJson> entry : options.entrySet()) { runOptions.add(entry.getValue().toSuite(entry.getKey())); } return runOptions.build(); }
@Test public void testImmutableMapJsonCodec() throws Exception { JsonCodec<Map<String, ImmutablePerson>> jsonCodec = mapJsonCodec(String.class, ImmutablePerson.class); ImmutablePerson.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testMapJsonCodec() throws Exception { JsonCodec<Map<String, Person>> jsonCodec = mapJsonCodec(String.class, Person.class); Person.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testMapJsonCodec() throws Exception { JsonCodec<Map<String, Person>> jsonCodec = mapJsonCodec(String.class, Person.class); Person.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testMapJsonCodec() throws Exception { JsonCodec<Map<String, Person>> jsonCodec = mapJsonCodec(String.class, Person.class); Person.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testImmutableMapJsonCodec() throws Exception { JsonCodec<Map<String, ImmutablePerson>> jsonCodec = mapJsonCodec(String.class, ImmutablePerson.class); ImmutablePerson.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testImmutableMapJsonCodec() throws Exception { JsonCodec<Map<String, ImmutablePerson>> jsonCodec = mapJsonCodec(String.class, ImmutablePerson.class); ImmutablePerson.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testMapNullValues() { JsonCodec<Map<String, String>> jsonCodec = mapJsonCodec(String.class, String.class); Map<String, String> map = new HashMap<>(); map.put("x", null); map.put("y", "abc"); assertEquals(jsonCodec.fromJson(jsonCodec.toJson(map)), map); }
@Test public void testMapNullValues() { JsonCodec<Map<String, String>> jsonCodec = mapJsonCodec(String.class, String.class); Map<String, String> map = new HashMap<>(); map.put("x", null); map.put("y", "abc"); assertEquals(jsonCodec.fromJson(jsonCodec.toJson(map)), map); }
@Test public void testImmutableMapJsonCodecFromJsonCodec() throws Exception { JsonCodec<Map<String, ImmutablePerson>> jsonCodec = mapJsonCodec(String.class, jsonCodec(ImmutablePerson.class)); ImmutablePerson.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testMapJsonCodecFromJsonCodec() throws Exception { JsonCodec<Map<String, Person>> jsonCodec = mapJsonCodec(String.class, jsonCodec(Person.class)); Person.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testMapJsonCodecFromJsonCodec() throws Exception { JsonCodec<Map<String, Person>> jsonCodec = mapJsonCodec(String.class, jsonCodec(Person.class)); Person.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testImmutableMapJsonCodecFromJsonCodec() throws Exception { JsonCodec<Map<String, ImmutablePerson>> jsonCodec = mapJsonCodec(String.class, jsonCodec(ImmutablePerson.class)); ImmutablePerson.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testMapJsonCodecFromJsonCodec() throws Exception { JsonCodec<Map<String, Person>> jsonCodec = mapJsonCodec(String.class, jsonCodec(Person.class)); Person.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testImmutableMapJsonCodecFromJsonCodec() throws Exception { JsonCodec<Map<String, ImmutablePerson>> jsonCodec = mapJsonCodec(String.class, jsonCodec(ImmutablePerson.class)); ImmutablePerson.validatePersonMapJsonCodec(jsonCodec); }
@Test public void testBasicGet() throws Throwable { Map<String, Object> response = client.execute( prepareGet().setUri(server.getBaseUrl().resolve("/foo")).build(), createJsonResponseHandler(mapJsonCodec(String.class, Object.class))); assertEquals(response.get("REQUEST_METHOD"), "GET"); assertEquals(response.get("SCRIPT_NAME"), ""); assertEquals(response.get("PATH_INFO"), "/foo"); assertEquals(response.get("QUERY_STRING"), ""); }
@Test public void testGetWithEscaping() throws Throwable { String path = "/hello%20world+bye"; Map<String, Object> response = client.execute( prepareGet().setUri(server.getBaseUrl().resolve(path + "?foo%2Fbar=123%20999")).build(), createJsonResponseHandler(mapJsonCodec(String.class, Object.class))); assertEquals(response.get("REQUEST_METHOD"), "GET"); assertEquals(response.get("SCRIPT_NAME"), ""); assertEquals(response.get("PATH_INFO"), "/hello%20world+bye"); assertEquals(response.get("QUERY_STRING"), "foo%2Fbar=123%20999"); } }
@Test public void testSettingCookiesResultsInACookieHashInRuby() throws Throwable { Map<String, String> response = client.execute( prepareGet() .setUri(server.getBaseUrl().resolve("/header-cookies-json")) .addHeader("COOKIE", "Cookie1=Value1") .addHeader("COOKIE", "Cookie2=Value2") .build(), createJsonResponseHandler(JsonCodec.mapJsonCodec(String.class, String.class))); assertEquals(response, ImmutableMap.of("Cookie1","Value1","Cookie2","Value2")); }
.setBodyGenerator(jsonBodyGenerator(jsonCodec(Object.class), announcement)) .build(); JsonResponse<Map<String, Object>> createResponse = client.execute(request, createFullJsonResponseHandler(mapJsonCodec(String.class, Object.class)));