public ImmutableList<GlobalSetting> parse(final InputStream is) { return Jsons.toObjects(is, GlobalSetting.class); } }
public static <T> ImmutableList<T> toObjects(final InputStream stream, final Class<T> elementClass) { return toObjects(of(stream), elementClass); }
public static <T> ImmutableList<T> toObjects(final String value, final Class<T> elementClass) { return toObjects(new ByteArrayInputStream(value.getBytes()), elementClass); }
private ImmutableList<Session> restoreSessions(final File file) { try { InputStream inputStream = new FileInputStream(file); return Jsons.toObjects(inputStream, Session.class); } catch (MocoException me) { logger.error("exception found", me); return of(); } catch (IOException e) { throw new MocoException(e); } }
public final T parseServer(final ImmutableList<InputStream> streams, final Optional<Integer> port, final MocoConfig... configs) { ImmutableList<SessionSetting> settings = Jsons.toObjects(streams, SessionSetting.class); return createServer(settings, port, configs); } }
private List<Plain> asPlains(final HttpResponse response) throws IOException { HttpEntity entity = checkJsonResponse(response); return Jsons.toObjects(entity.getContent(), Plain.class); }
@Test public void should_get_all_resource() throws IOException { runWithConfiguration("rest/rest.json"); org.apache.http.HttpResponse response = helper.getResponseWithHeader(remoteUrl("/all-resources"), of(HttpHeaders.CONTENT_TYPE, "application/json")); assertThat(response.getStatusLine().getStatusCode(), is(200)); HttpEntity entity = response.getEntity(); List<Plain> plains = Jsons.toObjects(entity.getContent(), Plain.class); assertThat(plains.size(), is(2)); }
@Override public void run() throws Exception { List<Plain> plains = Jsons.toObjects(helper.get(remoteUrl("/targets?foo=bar")), Plain.class); assertThat(plains.size(), is(2)); HttpResponse response = helper.getResponse(remoteUrl("/targets")); assertThat(response.getStatusLine().getStatusCode(), is(404)); } });
public ImmutableList<GlobalSetting> parse(final InputStream is) { return Jsons.toObjects(is, GlobalSetting.class); } }
public T parseServer(final ImmutableList<InputStream> streams, final Optional<Integer> port, final MocoConfig... configs) { ImmutableList<SessionSetting> settings = Jsons.toObjects(streams, SessionSetting.class); return createServer(settings, port, configs); } }