Example usage for junit.framework Assert assertNull

List of usage examples for junit.framework Assert assertNull

Introduction

In this page you can find the example usage for junit.framework Assert assertNull.

Prototype

static public void assertNull(Object object) 

Source Link

Document

Asserts that an object is null.

Usage

From source file:org.openmrs.api.VisitServiceTest.java

@Test
@Verifies(value = "should unretire given visit type", method = "unretireVisitType(VisitType)")
public void unretireVisitType_shouldUnretireGivenVisitType() throws Exception {
    VisitType visitType = Context.getVisitService().getVisitType(3);
    assertNotNull(visitType);//from w w w. j  a v a  2  s .c  o  m
    assertTrue(visitType.isRetired());
    assertEquals("Some Retire Reason", visitType.getRetireReason());

    Context.getVisitService().unretireVisitType(visitType);

    visitType = Context.getVisitService().getVisitType(3);
    assertNotNull(visitType);
    Assert.assertFalse(visitType.isRetired());
    Assert.assertNull(visitType.getRetireReason());

    //Should not change the number of visit types.
    assertEquals(3, Context.getVisitService().getAllVisitTypes().size());
}

From source file:org.openmrs.api.VisitServiceTest.java

@Test
@Verifies(value = "should delete given visit type", method = "purgeVisitType(VisitType)")
public void purgeVisitType_shouldDeleteGivenVisitType() throws Exception {
    VisitType visitType = Context.getVisitService().getVisitType(3);
    assertNotNull(visitType);/*from   w w  w  .ja  va  2  s . c  o  m*/

    Context.getVisitService().purgeVisitType(visitType);

    visitType = Context.getVisitService().getVisitType(3);
    Assert.assertNull(visitType);

    //Should reduce the existing number of visit types.
    assertEquals(2, Context.getVisitService().getAllVisitTypes().size());
}

From source file:org.openmrs.api.VisitServiceTest.java

/**
 * @see VisitService#saveVisit(Visit)//www . ja  v  a  2 s.c  om
 */
@Test
@Verifies(value = "should update an existing visit in the database", method = "saveVisit(Visit)")
public void saveVisit_shouldUpdateAnExistingVisitInTheDatabase() throws Exception {
    Visit visit = Context.getVisitService().getVisit(2);
    Assert.assertNull(visit.getLocation());//this is the field we are editing
    Assert.assertNull(visit.getChangedBy());
    Assert.assertNull(visit.getDateChanged());
    visit.setLocation(Context.getLocationService().getLocation(1));
    visit = Context.getVisitService().saveVisit(visit);

    Context.flushSession();
    assertNotNull(visit.getChangedBy());
    assertNotNull(visit.getDateChanged());
    assertEquals(Integer.valueOf(1), visit.getLocation().getLocationId());
}

From source file:org.openmrs.api.VisitServiceTest.java

/**
 * @see VisitService#voidVisit(Visit,String)
 *///from  ww  w . j a  va  2 s. c  o m
@Test
@Verifies(value = "should void the visit and set the voidReason", method = "voidVisit(Visit,String)")
public void voidVisit_shouldVoidTheVisitAndSetTheVoidReason() throws Exception {
    Visit visit = Context.getVisitService().getVisit(1);
    Assert.assertFalse(visit.isVoided());
    Assert.assertNull(visit.getVoidReason());
    Assert.assertNull(visit.getVoidedBy());
    Assert.assertNull(visit.getDateVoided());

    visit = Context.getVisitService().voidVisit(visit, "test reason");
    assertTrue(visit.isVoided());
    assertEquals("test reason", visit.getVoidReason());
    assertEquals(Context.getAuthenticatedUser(), visit.getVoidedBy());
    assertNotNull(visit.getDateVoided());
}

From source file:org.openmrs.api.VisitServiceTest.java

/**
 * @see VisitService#unvoidVisit(Visit)//from  w  w  w  .jav  a2s .  c om
 */
@Test
@Verifies(value = "should unvoid the visit and unset all the void related fields", method = "unvoidVisit(Visit)")
public void unvoidVisit_shouldUnvoidTheVisitAndUnsetAllTheVoidRelatedFields() throws Exception {
    Visit visit = Context.getVisitService().getVisit(6);
    assertTrue(visit.isVoided());
    assertNotNull(visit.getVoidReason());
    assertNotNull(visit.getVoidedBy());
    assertNotNull(visit.getDateVoided());

    visit = Context.getVisitService().unvoidVisit(visit);
    Assert.assertFalse(visit.isVoided());
    Assert.assertNull(visit.getVoidReason());
    Assert.assertNull(visit.getVoidedBy());
    Assert.assertNull(visit.getDateVoided());
}

From source file:org.openmrs.api.VisitServiceTest.java

/**
 * @see VisitService#getVisitAttributeType(Integer)
 * @verifies return null if no visit attribute type exists with the given id
 *//*  www .  ja v  a2  s.c o m*/
@Test
public void getVisitAttributeType_shouldReturnNullIfNoVisitAttributeTypeExistsWithTheGivenId()
        throws Exception {
    executeDataSet(VISITS_ATTRIBUTES_XML);
    Assert.assertNull(visitService.getVisitAttributeType(999));
}

From source file:org.openmrs.api.VisitServiceTest.java

/**
 * @see VisitService#getVisitAttributeTypeByUuid(String)
 * @verifies return null if no visit attribute type exists with the given uuid
 *//*from  w ww.j  av  a  2s .com*/
@Test
public void getVisitAttributeTypeByUuid_shouldReturnNullIfNoVisitAttributeTypeExistsWithTheGivenUuid()
        throws Exception {
    executeDataSet(VISITS_ATTRIBUTES_XML);
    Assert.assertNull(visitService.getVisitAttributeTypeByUuid("not-a-uuid"));
}

From source file:org.openmrs.api.VisitServiceTest.java

/**
 * @see VisitService#unretireVisitAttributeType(VisitAttributeType)
 * @verifies unretire a retired visit attribute type
 */// w ww .j a va2  s. c om
@Test
public void unretireVisitAttributeType_shouldUnretireARetiredVisitAttributeType() throws Exception {
    executeDataSet(VISITS_ATTRIBUTES_XML);
    VisitAttributeType vat = visitService.getVisitAttributeType(2);
    assertTrue(vat.isRetired());
    assertNotNull(vat.getDateRetired());
    assertNotNull(vat.getRetiredBy());
    assertNotNull(vat.getRetireReason());
    visitService.unretireVisitAttributeType(vat);
    Assert.assertFalse(vat.isRetired());
    Assert.assertNull(vat.getDateRetired());
    Assert.assertNull(vat.getRetiredBy());
    Assert.assertNull(vat.getRetireReason());
}

From source file:org.openmrs.api.VisitServiceTest.java

/**
 * @see VisitService#getVisitAttributeByUuid(String)
 * @verifies return null if no visit attribute has the given uuid
 *///ww w . ja  v a 2  s . c  o m
@Test
public void getVisitAttributeByUuid_shouldReturnNullIfNoVisitAttributeHasTheGivenUuid() throws Exception {
    executeDataSet(VISITS_ATTRIBUTES_XML);
    Assert.assertNull(visitService.getVisitAttributeByUuid("not-a-uuid"));
}

From source file:org.openmrs.api.VisitServiceTest.java

/**
 * @see VisitService#endVisit(Visit,Date)
 *//*from   ww  w.  jav a2 s  .c om*/
@Test
@Verifies(value = "should set stopDateTime as currentDate if stopDate is null", method = "endVisit(Visit,Date)")
public void endVisit_shouldSetStopDateTimeAsCurrentDateIfStopDateIsNull() throws Exception {
    VisitService vs = Context.getVisitService();
    Visit visit = vs.getVisit(1);
    Assert.assertNull(visit.getStopDatetime());
    vs.endVisit(visit, null);
    assertNotNull(visit.getStopDatetime());
}