@Test public final void givenNewHometown_whenUpdate_thenNewHometownPersisted() { // create and insert person document JsonDocument doc = insertRandomPersonDocument(); // update person Person expected = converter.fromDocument(doc); String updatedHomeTown = RandomStringUtils.randomAlphabetic(12); expected.setHomeTown(updatedHomeTown); personService.update(expected); // check results JsonDocument actual = bucket.get(expected.getId()); assertNotNull(actual); assertNotNull(actual.content()); assertEquals(expected.getHomeTown(), actual.content().getString("homeTown")); // cleanup bucket.remove(expected.getId()); }
@Override protected String run() { // TODO Auto-generated method stub JsonDocument jsonDoc = resource.read(productId); int latent = Util.generateRandom(); System.out.println(latent * 1000); latentResource.addLatency(latent * 1000); JsonObject obj = jsonDoc.content(); System.out.println("inside hystrix command run method " + obj.toString()); return obj.toString(); }
@Test public final void givenPersons_whenUpdateBulk_thenPersonsAreUpdated() { List<String> ids = new ArrayList<>(); // add some person documents for (int i = 0; i < 5; i++) { ids.add(insertRandomPersonDocument().id()); } // load persons from Couchbase List<Person> persons = new ArrayList<>(); for (String id : ids) { persons.add(converter.fromDocument(bucket.get(id))); } // modify persons for (Person person : persons) { person.setHomeTown(RandomStringUtils.randomAlphabetic(10)); } // perform bulk update personService.updateBulk(persons); // check results for (Person person : persons) { JsonDocument doc = bucket.get(person.getId()); assertEquals(person.getName(), doc.content().getString("name")); assertEquals(person.getHomeTown(), doc.content().getString("homeTown")); } // cleanup for (String id : ids) { bucket.remove(id); } }