public void testCreateEntry() throws Exception { Preference pref = helper.makeDummyPreference(); RequestContext req = createRequestContext(pref); ResponseContext res = adapter.postEntry(req); assertNotNull("Null response context", res); assertEquals("Incorrect response status", 201, res.getStatus()); assertNotNull("Null etag", res.getEntityTag()); // disable last modified check til mock dao bumps modified date // assertNotNull("Null last modified", res.getLastModified()); assertNotNull("Null Location header", res.getHeader("Location")); assertNotNull("Null Content-Location header", res.getHeader("Content-Location")); String username = helper.getUser().getUsername(); Preference saved = helper.getUserService().getUser(username).getPreference(pref.getKey()); assertNotNull("Preference not saved", saved); assertEquals("Wrong key", pref.getKey(), saved.getKey()); assertEquals("Wrong value", pref.getValue(), saved.getValue()); }
public void testCreateEntry() throws Exception { CollectionItem collection = helper.makeAndStoreDummyCollection(); Ticket ticket = helper.makeDummyTicket(); ticket.setKey("createEntryTicket"); RequestContext req = createRequestContext(collection, ticket); ResponseContext res = adapter.postEntry(req); assertNotNull("Null response context", res); assertEquals("Incorrect response status", 201, res.getStatus()); assertNotNull("Null etag", res.getEntityTag()); // disable last modified check til mock dao bumps modified date // assertNotNull("Null last modified", res.getLastModified()); assertNotNull("Null Location header", res.getHeader("Location")); assertNotNull("Null Content-Location header", res.getHeader("Content-Location")); String username = helper.getUser().getUsername(); Ticket saved = helper.getContentService().getTicket(collection, ticket.getKey()); assertNotNull("Ticket not saved", saved); assertEquals("Wrong key", ticket.getKey(), saved.getKey()); assertEquals("Wrong type", ticket.getType(), saved.getType()); }