Package com.cloudburo.entity

Examples of com.cloudburo.entity.Customer


     
    HttpServletRequest request = mock(HttpServletRequest.class);
    HttpServletResponse response = mock(HttpServletResponse.class);
     
      // A customer object test entry
      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();
View Full Code Here


    Date inDate = new Date();
    LocalDateTime in1Date = new LocalDateTime();
    DateTime in2Date = new DateTime();
      // A customer object test entry
      Customer customerIn = new Customer();
      customerIn.name = "Felix";
      customerIn.address = "Test";
      customerIn.date = inDate;
      customerIn.date1 = in1Date;
      customerIn.date2 = in2Date;

      // TEST: Check the persistence operations "POST"
      Customer customerOut =  persistTestRecord(customerIn);
      assertEquals("Checking name", customerOut.name, customerIn.name);
      assertEquals("Checking id", customerOut._id > 0,true);
     
      // TEST: Check the retrieval of the collections "GET"
      JsonArray array = getTestCollection(null);
      // Expect an array with the last entry must be a meta data record (with a attribute _cursor)
      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"
      // Expect a single entry which can be converted in our domain object and correct attributes
      customerOut =  getTestRecord(customerOut._id,null);
      assertEquals("Checking Name", customerOut.name, customerIn.name);
      assertEquals("Checking Surname", customerOut.surname, customerIn.surname);
      // 2014-06-14T15:17:20.262Z
      assertEquals("Checking Date", customerOut.date,inDate);
      // 2014-06-14T17:17:20.320
      assertEquals("Checking Joda DateTime", customerOut.date1,in1Date);
      //
      assertEquals("Checking Joda DateTime", customerOut.date2,in2Date);     
      // TEST: Going to delete the entry "DELETE"
      StringWriter outputStringWriter = new StringWriter();
      when(request.getPathInfo()).thenReturn("/"+customerOut._id);
      when(response.getWriter()).thenReturn(new PrintWriter(outputStringWriter));
      customerServlet.doDelete(request, response);

      // TEST: We shouldn't get any data back (i.e. deleted)
      outputStringWriter =  getTestRecordStringWriter(customerOut._id);
      assertEquals("Checking empty JSON","{}", outputStringWriter.toString());
     
      // TEST: Paging functionality
      // Add 4 records
      customerIn = new Customer();
      customerIn.name = "Name1";
      customerIn.surname = "Surname1";
      customerIn.address = "Address1";
      persistTestRecord(customerIn);
      customerIn.name = "Name2";
View Full Code Here

TOP

Related Classes of com.cloudburo.entity.Customer

Copyright © 2018 www.massapicom. 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.