@Test public void shouldReturnTheCorrectPersonFromAnyStatusUpdate() throws Exception { Person person = getRandomPerson(); person.addContextStatus("Foo", null, null); person.addContextStatus("Bar", null, null); person.addContextStatus("Baz", null, null); for (ContextUpdates status : person.getStatus()) { assertThat(status.getPerson(), equalTo(person)); System.out.println("Person: " + status.getPerson() + " Status: " + status.getStatusText()); } // for ( Node node : index.query( "name", "*e*" ) ) // { // // This will return // Person p = new Person(node); // System.out.println(p.getName()); // System.out.println(p.getCompany()); // } for (Node node : indexStatus.query(ShortTermCtxTypes.STATUS, "*o*")) { // This will return ContextUpdates s = new ContextUpdates(node); System.out.println(s.getStatusText()); } }
@Test public void addStatusAndRetrieveIt() throws Exception { for (int i = 0; i < 20; i++) { Person person = getRandomPerson(); person.addContextStatus("Testing!", "School", null); ContextUpdates update = person.getStatus().iterator().next(); assertThat(update, CoreMatchers.<Object>notNullValue()); assertThat(update.getStatusText(), equalTo("Testing!")); assertThat(update.getPerson(), equalTo(person)); System.out.println("Person: " + person.getName() + " Status: " + update.getStatusText()); } }
@Test public void retrieveStatusUpdatesInDateOrder() throws Exception { Person person = getRandomPersonWithFriends(); int numberOfStatuses = 20; for (int i = 0; i < numberOfStatuses; i++) { Person friend = getRandomFriendOf(person); friend.addContextStatus("Dum-deli-dum...", "location", null); } ArrayList<ContextUpdates> updates = fromIterableToArrayList(person.friendStatuses()); assertThat(updates.size(), equalTo(numberOfStatuses)); assertUpdatesAreSortedByDate(updates); }
@Test public void multipleStatusesComeOutInTheRightOrder() throws Exception { ArrayList<String> statuses = new ArrayList<String>(); statuses.add("Test1"); statuses.add("Test2"); statuses.add("Test3"); Person person = getRandomPerson(); for (String status : statuses) { person.addContextStatus(status, "location", null); } int i = statuses.size(); for (ContextUpdates update : person.getStatus()) { i--; assertThat(update.getStatusText(), equalTo(statuses.get(i))); System.out.println("Person: " + person.getName() + " Status: " + update.getStatusText()); } }