List of usage examples for junit.framework Assert assertNull
static public void assertNull(Object object)
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.AllergyControllerTest.java
/** * @see AllergyController#getAllergy(String,WebRequest) * @verifies get a default representation of an allergy */// w w w.j av a 2s . c o m @Test public void getAllergy_shouldGetADefaultRepresentationOfAnAllergy() throws Exception { Object result = new AllergyController().retrieve(ResourceTestConstants.ALLERGY_UUID, emptyRequest()); Assert.assertNotNull(result); Util.log("Allergy fetched (default)", result); Assert.assertEquals(ResourceTestConstants.ALLERGY_UUID, PropertyUtils.getProperty(result, "uuid")); Assert.assertNotNull(PropertyUtils.getProperty(result, "links")); Assert.assertNotNull(PropertyUtils.getProperty(result, "person")); Assert.assertNotNull(PropertyUtils.getProperty(result, "allergen")); Assert.assertNull(PropertyUtils.getProperty(result, "auditInfo")); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.AllergyController1_8Test.java
/** * @see AllergyController#getAllergy(String,WebRequest) * @verifies get a default representation of an allergy *//* www .j av a2 s .co m*/ @Test public void getAllergy_shouldGetADefaultRepresentationOfAnAllergy() throws Exception { SimpleObject result = deserialize( handle(newGetRequest(getURI() + "/" + RestTestConstants1_8.ALLERGY_UUID))); Assert.assertNotNull(result); Util.log("Allergy fetched (default)", result); Assert.assertEquals(RestTestConstants1_8.ALLERGY_UUID, PropertyUtils.getProperty(result, "uuid")); Assert.assertNotNull(PropertyUtils.getProperty(result, "links")); Assert.assertNotNull(PropertyUtils.getProperty(result, "person")); Assert.assertNotNull(PropertyUtils.getProperty(result, "allergen")); Assert.assertNull(PropertyUtils.getProperty(result, "auditInfo")); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.PersonNameController1_8Test.java
@Test public void shouldPurgeName() throws Exception { int before = service.getPersonByUuid(personUuid).getNames().size(); handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("purge", ""))); int after = service.getPersonByUuid(personUuid).getNames().size(); Assert.assertNull(service.getPersonNameByUuid(getUuid())); Assert.assertEquals(before - 1, after); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.ProblemController1_8Test.java
@Test public void getProblem_shouldGetADefaultRepresentationOfAProblem() throws Exception { SimpleObject result = deserialize(handle(newGetRequest(getURI() + "/" + getUuid()))); Assert.assertNotNull(result);//from w ww .j a v a 2 s. co m Util.log("Problem fetched (default)", result); Assert.assertEquals(getUuid(), PropertyUtils.getProperty(result, "uuid")); Assert.assertNotNull(PropertyUtils.getProperty(result, "links")); Assert.assertNotNull(PropertyUtils.getProperty(result, "person")); Assert.assertNotNull(PropertyUtils.getProperty(result, "problem")); Assert.assertNotNull(PropertyUtils.getProperty(result, "sortWeight")); Assert.assertNull(PropertyUtils.getProperty(result, "auditInfo")); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.ProblemControllerTest.java
/** * @see ProblemController#getProblem(String,WebRequest) * @verifies get a default representation of a problem *//*from w ww .j a v a2 s .com*/ @Test public void getProblem_shouldGetADefaultRepresentationOfAProblem() throws Exception { Object result = new ProblemController().retrieve(ResourceTestConstants.PROBLEM_UUID, emptyRequest()); Assert.assertNotNull(result); Util.log("Problem fetched (default)", result); Assert.assertEquals(ResourceTestConstants.PROBLEM_UUID, PropertyUtils.getProperty(result, "uuid")); Assert.assertNotNull(PropertyUtils.getProperty(result, "links")); Assert.assertNotNull(PropertyUtils.getProperty(result, "person")); Assert.assertNotNull(PropertyUtils.getProperty(result, "problem")); Assert.assertNull(PropertyUtils.getProperty(result, "auditInfo")); }
From source file:org.openmrs.ProviderTest.java
/** * @see {@link Provider#setPerson(Person)} *//*from w w w. j ava 2 s . c o m*/ @Test @Verifies(value = "should blank out name if set to non null person", method = "setPerson(Person)") public void setPerson_shouldBlankOutNameIfSetToNonNullPerson() throws Exception { final String providerName = "Provider Name"; final String nameField = "name"; Provider provider = new Provider(); provider.setName(providerName); Assert.assertEquals(providerName, FieldUtils.readField(provider, nameField, true)); Person person = new Person(1); person.addName(new PersonName("givenName", "middleName", "familyName")); provider.setPerson(person); Assert.assertNull(FieldUtils.readField(provider, nameField, true)); }
From source file:org.osaf.cosmo.calendar.EntityConverterTest.java
public void testEntityConverterTask() throws Exception { Calendar calendar = getCalendar("vtodo.ics"); NoteItem note = converter.convertTaskCalendar(calendar); Assert.assertTrue(TriageStatus.CODE_NOW == note.getTriageStatus().getCode()); // add COMPLETED DateTime completeDate = new DateTime("20080122T100000Z"); VToDo vtodo = (VToDo) calendar.getComponents(Component.VTODO).get(0); ICalendarUtils.setCompleted(completeDate, vtodo); note = converter.convertTaskCalendar(calendar); TriageStatus ts = note.getTriageStatus(); Assert.assertTrue(TriageStatus.CODE_DONE == ts.getCode()); Assert.assertTrue(TriageStatusUtil.getDateFromRank(ts.getRank()).getTime() == completeDate.getTime()); note.setTriageStatus(null);//www. j a v a 2s. c o m ICalendarUtils.setCompleted(null, vtodo); Assert.assertNull(vtodo.getDateCompleted()); ICalendarUtils.setStatus(Status.VTODO_COMPLETED, vtodo); // verify that TriageStatus.rank is set ot current time when // STATUS:COMPLETED is present and COMPLETED is not present long begin = (System.currentTimeMillis() / 1000) * 1000; note = converter.convertTaskCalendar(calendar); long end = (System.currentTimeMillis() / 1000) * 1000; ts = note.getTriageStatus(); Assert.assertTrue(TriageStatus.CODE_DONE == ts.getCode()); long rankTime = TriageStatusUtil.getDateFromRank(ts.getRank()).getTime(); Assert.assertTrue(rankTime <= end && rankTime >= begin); }
From source file:org.osaf.cosmo.calendar.EntityConverterTest.java
public void testConvertTask() throws Exception { TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); NoteItem master = new MockNoteItem(); master.setDisplayName("displayName"); master.setBody("body"); master.setIcalUid("icaluid"); master.setClientModifiedDate(new DateTime("20070101T100000Z")); master.setTriageStatus(TriageStatusUtil.initialize(new MockTriageStatus())); Calendar cal = converter.convertNote(master); cal.validate();//from w w w. java 2s .co m Assert.assertEquals(1, cal.getComponents().size()); ComponentList comps = cal.getComponents(Component.VTODO); Assert.assertEquals(1, comps.size()); VToDo task = (VToDo) comps.get(0); Assert.assertNull(task.getDateCompleted()); Assert.assertNull(ICalendarUtils.getXProperty("X-OSAF-STARRED", task)); DateTime completeDate = new DateTime("20080122T100000Z"); master.getTriageStatus().setCode(TriageStatus.CODE_DONE); master.getTriageStatus().setRank(TriageStatusUtil.getRank(completeDate.getTime())); master.addStamp(new MockTaskStamp()); cal = converter.convertNote(master); task = (VToDo) cal.getComponents().get(0); Completed completed = task.getDateCompleted(); Assert.assertNotNull(completed); Assert.assertEquals(completeDate.getTime(), completed.getDate().getTime()); Assert.assertEquals("TRUE", ICalendarUtils.getXProperty("X-OSAF-STARRED", task)); }
From source file:org.osaf.cosmo.calendar.EntityConverterTest.java
public void testConvertEvent() throws Exception { TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); NoteItem master = new MockNoteItem(); master.setDisplayName("displayName"); master.setBody("body"); master.setIcalUid("icaluid"); master.setClientModifiedDate(new DateTime("20070101T100000Z")); EventStamp eventStamp = new MockEventStamp(master); eventStamp.createCalendar();// w w w.ja v a 2 s. c o m eventStamp.setStartDate(new DateTime("20070212T074500")); master.addStamp(eventStamp); Calendar cal = converter.convertNote(master); cal.validate(); // date has no timezone, so there should be no timezones Assert.assertEquals(0, cal.getComponents(Component.VTIMEZONE).size()); eventStamp.setStartDate(new DateTime("20070212T074500", TIMEZONE_REGISTRY.getTimeZone("America/Chicago"))); cal = converter.convertNote(master); cal.validate(); // should be a single VEVENT ComponentList comps = cal.getComponents(Component.VEVENT); Assert.assertEquals(1, comps.size()); VEvent event = (VEvent) comps.get(0); // test VALUE=DATE-TIME is not present Assert.assertNull(event.getStartDate().getParameter(Parameter.VALUE)); // test item properties got merged into calendar Assert.assertEquals("displayName", event.getSummary().getValue()); Assert.assertEquals("body", event.getDescription().getValue()); Assert.assertEquals("icaluid", event.getUid().getValue()); Assert.assertEquals(master.getClientModifiedDate().getTime(), event.getDateStamp().getDate().getTime()); // date has timezone, so there should be a timezone Assert.assertEquals(1, cal.getComponents(Component.VTIMEZONE).size()); eventStamp .setEndDate(new DateTime("20070212T074500", TIMEZONE_REGISTRY.getTimeZone("America/Los_Angeles"))); cal = converter.convertNote(master); cal.validate(); // dates have 2 different timezones, so there should be 2 timezones Assert.assertEquals(2, cal.getComponents(Component.VTIMEZONE).size()); // add timezones to master event calendar eventStamp.getEventCalendar().getComponents().add(registry.getTimeZone("America/Chicago").getVTimeZone()); eventStamp.getEventCalendar().getComponents() .add(registry.getTimeZone("America/Los_Angeles").getVTimeZone()); cal = converter.convertNote(master); cal.validate(); Assert.assertEquals(2, cal.getComponents(Component.VTIMEZONE).size()); }
From source file:org.osaf.cosmo.calendar.EntityConverterTest.java
public void testInheritedAnyTime() throws Exception { NoteItem master = new MockNoteItem(); EventStamp eventStamp = new MockEventStamp(master); eventStamp.createCalendar();/*ww w. j a v a2s . c o m*/ eventStamp.setStartDate(new DateTime("20070212T074500")); eventStamp.setAnyTime(true); DateList dates = new ICalDate(";VALUE=DATE-TIME:20070212T074500,20070213T074500").getDateList(); eventStamp.setRecurrenceDates(dates); master.addStamp(eventStamp); NoteItem mod = new MockNoteItem(); mod.setModifies(master); master.addModification(mod); EventExceptionStamp exceptionStamp = new MockEventExceptionStamp(mod); mod.addStamp(exceptionStamp); exceptionStamp.createCalendar(); exceptionStamp.setRecurrenceId(new DateTime("20070212T074500")); exceptionStamp.setStartDate(new DateTime("20070212T074500")); exceptionStamp.setAnyTime(null); mod.addStamp(exceptionStamp); Calendar cal = converter.convertNote(master); cal.validate(); ComponentList comps = cal.getComponents(Component.VEVENT); Assert.assertEquals(2, comps.size()); VEvent masterEvent = (VEvent) comps.get(0); VEvent modEvent = (VEvent) comps.get(1); Parameter masterAnyTime = masterEvent.getStartDate().getParameter("X-OSAF-ANYTIME"); Parameter modAnyTime = modEvent.getStartDate().getParameter("X-OSAF-ANYTIME"); Assert.assertNotNull(masterAnyTime); Assert.assertEquals("TRUE", masterAnyTime.getValue()); Assert.assertNotNull(modAnyTime); Assert.assertEquals("TRUE", modAnyTime.getValue()); // change master and verify attribute is inherited in modification eventStamp.setAnyTime(false); cal = converter.convertNote(master); cal.validate(); comps = cal.getComponents(Component.VEVENT); Assert.assertEquals(2, comps.size()); masterEvent = (VEvent) comps.get(0); modEvent = (VEvent) comps.get(1); Assert.assertNull(masterEvent.getStartDate().getParameter("X-OSAF-ANYTIME")); Assert.assertNull(modEvent.getStartDate().getParameter("X-OSAF-ANYTIME")); // change both and verify exceptionStamp.setAnyTime(true); cal = converter.convertNote(master); cal.validate(); comps = cal.getComponents(Component.VEVENT); Assert.assertEquals(2, comps.size()); masterEvent = (VEvent) comps.get(0); modEvent = (VEvent) comps.get(1); modAnyTime = modEvent.getStartDate().getParameter("X-OSAF-ANYTIME"); Assert.assertNull(masterEvent.getStartDate().getParameter("X-OSAF-ANYTIME")); Assert.assertNotNull(modAnyTime); Assert.assertEquals("TRUE", modAnyTime.getValue()); }