Examples of GsonWrapper


Examples of com.cloudburo.servlet.GsonWrapper

      Customer customerIn = new Customer();
      customerIn.name = "Felix";
      customerIn.address = "Kuestahler";
      customerIn.date = new Date();
      customerIn.date1 = new LocalDateTime();
      String customerInJSON = (new GsonWrapper()).getGson().toJson(customerIn);
     
      logger.log(Level.INFO, "Going to persist {0}", customerInJSON);
      StringWriter stringWriter = new StringWriter();
     
      // TEST: Check the persistence operations "POST"
      when(request.getReader()).thenReturn(new BufferedReader(new StringReader(customerInJSON)));
      when(response.getWriter()).thenReturn(new PrintWriter(stringWriter));
     
      customerServlet.doPost(request, response);

      Customer customerOut =  (new GsonWrapper()).getGson().fromJson(stringWriter.toString(), Customer.class);
      assertEquals("Checking name", customerOut.name, customerIn.name);
      assertEquals("Checking id", customerOut._id > 0,true);
     
      // TEST: Check the retrieval of the collections "GET"
      stringWriter = new StringWriter();
      when(request.getReader()).thenReturn(new BufferedReader(new StringReader("")));
      when(response.getWriter()).thenReturn(new PrintWriter(stringWriter));
     
      customerServlet.doGet(request, response);
     
      // Expect an array with the last entry must be a meta data record (with a attribute _cursor)
      JsonArray array = (new JsonParser()).parse(stringWriter.toString()).getAsJsonArray();
      assertEquals("Checking received numbers of JSON Elements", 2,array.size());
      JsonObject elem  = array.get(array.size()-1).getAsJsonObject();
      assertEquals("Checking that there is a 'cursor' elemen",elem.get("_cursor").getAsString().equals(""),true);

      // TEST: Check the retrieval of a single entry "GET"
      stringWriter = new StringWriter();
      when(request.getPathInfo()).thenReturn("/"+customerOut._id);
      when(response.getWriter()).thenReturn(new PrintWriter(stringWriter));
     
      customerServlet.doGet(request, response);
     
      // Expect a single entry which can be converted in our domain object and correct attributes
      customerOut =  (new GsonWrapper()).getGson().fromJson(stringWriter.toString(), Customer.class);
      assertEquals("Checking Name", customerOut.name, customerIn.name);
      assertEquals("Checking Surname", customerOut.surname, customerIn.surname);
     
      // TEST: Going to delete the entry "DELETE"
      stringWriter = new StringWriter();
View Full Code Here

Examples of foodev.jsondiff.jsonwrap.gson.GsonWrapper

import foodev.jsondiff.jsonwrap.gson.GsonWrapper;

public class GsonDiff extends JsonDiff {

  public GsonDiff() {
    super(new GsonWrapper());
  }
View Full Code Here

Examples of org.jclouds.json.internal.GsonWrapper

            .range(range)
            .build();
      assertThat(client.initiateJob(VAULT_NAME, retrieval)).isEqualTo(JOB_ID);

      RecordedRequest request = server.takeRequest();
      Json json = new GsonWrapper(new Gson());
      ArchiveRetrievalJobRequest job = json.fromJson(new String(request.getBody()), ArchiveRetrievalJobRequest.class);
      assertThat(job.getDescription()).isEqualTo(DESCRIPTION);
      assertThat(job.getRange()).isEqualTo(range);
      assertThat(job.getArchiveId()).isEqualTo(ARCHIVE_ID);
      assertThat(job.getType()).isEqualTo("archive-retrieval");
View Full Code Here

Examples of org.jclouds.json.internal.GsonWrapper

            .marker(marker)
            .build();
      assertThat(client.initiateJob(VAULT_NAME, job)).isEqualTo(JOB_ID);

      RecordedRequest request = server.takeRequest();
      Json json = new GsonWrapper(new Gson());
      job = json.fromJson(new String(request.getBody()), InventoryRetrievalJobRequest.class);
      assertThat(job.getFormat()).isEqualTo(format);
      assertThat(job.getParameters().getMarker()).isEqualTo(marker);
      assertThat(job.getParameters().getLimit()).isEqualTo(limit);
      assertThat(job.getParameters().getStartDate()).isEqualTo(startDate);
      assertThat(job.getParameters().getEndDate()).isEqualTo(endDate);
View Full Code Here

Examples of org.jclouds.json.internal.GsonWrapper

   private Binder binder;

   @BeforeGroups(groups = { "unit" })
   public void setup() {
      request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
      Json json = new GsonWrapper(new Gson());
      binder = new ProductOrderToJson(json);
   }
View Full Code Here

Examples of org.jclouds.json.internal.GsonWrapper

   private Json json;

   @BeforeClass
   public void init() {
      json = new GsonWrapper(new Gson());
   }
View Full Code Here

Examples of org.jclouds.json.internal.GsonWrapper

   private Binder binder;

   @BeforeGroups(groups = { "unit" })
   public void setup() {
      request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
      Json json = new GsonWrapper(new Gson());
      binder = new ProductOrderToJson(json);
   }
View Full Code Here

Examples of org.jclouds.json.internal.GsonWrapper

         "\"content_type\": \"application/unknown\"}]";

      InputStream stream = Strings2.toInputStream(jsonObjectList);

      ParseObjectInfoListFromJsonResponse parser =
         new ParseObjectInfoListFromJsonResponse(new GsonWrapper(new Gson()));

      GeneratedHttpRequest.Builder builder = new GeneratedHttpRequest.Builder();
      builder.method("method")
             .endpoint("http://test.org/test")
             .invocation(Invocation.create(Invokable.from(Object.class.getMethod("toString", null)),
View Full Code Here

Examples of org.jclouds.json.internal.GsonWrapper

   private Json json;

   @BeforeClass
   public void init() {
      json = new GsonWrapper(new Gson());
   }
View Full Code Here

Examples of org.jclouds.json.internal.GsonWrapper

   private Json json;

   @BeforeClass
   public void init() {
      json = new GsonWrapper(new Gson());
   }
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.