Exemplo n.º 1
0
 // This tests to see that the ObjectMapper serializes Date objects to the proper format
 @Test
 public void serializedDateDoesNotIncludeMilliseconds() throws JsonProcessingException {
   Date now =
       new Date(); // will be initialized to when it was allocated with millisecond precision
   SimpleDateFormat iso8601WithoutMilliseconds = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
   iso8601WithoutMilliseconds.setTimeZone(TimeZone.getTimeZone("UTC"));
   String expectedDate = "\"" + iso8601WithoutMilliseconds.format(now) + "\"";
   JsonProvider provider = new JsonProvider(config);
   ObjectMapper mapper = provider.locateMapper(Object.class, MediaType.APPLICATION_JSON_TYPE);
   String serializedDate = mapper.writeValueAsString(now);
   assertTrue(serializedDate.equals(expectedDate));
 }
Exemplo n.º 2
0
 public boolean sendAllItemsResponse() {
   ObjectNode event = JsonProvider.getAllItemsJson();
   if (event != null) {
     sendMessage(event);
     return true;
   } else {
     System.err.println("Error getting all items");
     return false;
   }
 }
Exemplo n.º 3
0
 public boolean sendViewBids(int userId) {
   ObjectNode event = JsonProvider.getViewBidsJson(userId);
   if (event != null) {
     sendMessage(event);
     return true;
   } else {
     System.err.println("Error getting viewBids");
     return false;
   }
 }
Exemplo n.º 4
0
 public boolean sendLogInResponse(User user) {
   ObjectNode event = JsonProvider.getLoginJson(user);
   if (event != null) {
     sendMessage(event);
     return true;
   } else {
     System.err.println("Error logging in");
     return false;
   }
 }
Exemplo n.º 5
0
 public boolean registerUser(User user) {
   ObjectNode event = JsonProvider.getRegisterJson(user);
   if (event.get("success").asBoolean()) {
     sendMessage(event);
     return true;
   } else {
     sendMessage(event);
     System.err.println("Error registering new user");
     return false;
   }
 }
Exemplo n.º 6
0
 private boolean isEnabled(JsonProvider provider, SerializationFeature feature) {
   ObjectMapper mapper = provider.locateMapper(Object.class, MediaType.APPLICATION_JSON_TYPE);
   SerializationConfig sConfig = mapper.getSerializationConfig();
   return sConfig.isEnabled(feature);
 }
Exemplo n.º 7
0
 public void sendConnectionId(String cid) {
   ObjectNode event = JsonProvider.getConnectionIdJson(cid);
   sendMessage(event);
 }
Exemplo n.º 8
0
 public void sendPlaceBid(Bid bid) {
   ObjectNode event = JsonProvider.getPlaceBidJson(bid);
   sendMessage(event);
 }
Exemplo n.º 9
0
 public void sendDeleteItem(int itemno) {
   ObjectNode event = JsonProvider.getDeleteItemJson(itemno);
   sendMessage(event);
 }
Exemplo n.º 10
0
 public void sendNewItem(Item item) {
   ObjectNode event = JsonProvider.getNewItemJson(item);
   sendMessage(event);
 }