Search in sources :

Example 16 with LocationTag

use of org.openmrs.LocationTag in project openmrs-core by openmrs.

the class LocationServiceTest method saveLocationTag_shouldReturnSavedObject.

/**
 * @see LocationService#saveLocationTag(LocationTag)
 */
@Test
public void saveLocationTag_shouldReturnSavedObject() {
    LocationTag locationTag = new LocationTag("Some tag name", "Some description");
    LocationTag savedLocationTag = Context.getLocationService().saveLocationTag(locationTag);
    Assert.assertEquals(locationTag, savedLocationTag);
}
Also used : LocationTag(org.openmrs.LocationTag) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 17 with LocationTag

use of org.openmrs.LocationTag in project openmrs-core by openmrs.

the class LocationServiceTest method purgeLocationTag_shouldDeleteLocationTag.

/**
 * Make sure that purging a location tag removes the row from the database
 *
 * @see LocationService#purgeLocationTag(LocationTag)
 */
@Test
public void purgeLocationTag_shouldDeleteLocationTag() {
    LocationService ls = Context.getLocationService();
    // Fetch the encounter to delete from the db
    LocationTag tag = ls.getLocationTag(5);
    ls.purgeLocationTag(tag);
    // Try to refetch the location. should get a null object
    LocationTag t = ls.getLocationTag(tag.getLocationTagId());
    assertNull("We shouldn't find the tag after deletion", t);
}
Also used : LocationTag(org.openmrs.LocationTag) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 18 with LocationTag

use of org.openmrs.LocationTag in project openmrs-core by openmrs.

the class LocationServiceTest method retireLocation_shouldNotRetireIndependentField.

/**
 * @see LocationService#retireLocation(Location location, String reason)
 */
@Test
public void retireLocation_shouldNotRetireIndependentField() {
    LocationService locationService = Context.getLocationService();
    Location location = new Location(1);
    location.setName("location to retire");
    LocationTag tag = new LocationTag(1);
    location.addTag(tag);
    locationService.retireLocation(location, "test retire reason");
    Assert.assertFalse(tag.getRetired());
}
Also used : LocationTag(org.openmrs.LocationTag) Location(org.openmrs.Location) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 19 with LocationTag

use of org.openmrs.LocationTag in project openmrs-core by openmrs.

the class LocationServiceTest method saveLocationTag_shouldThrowExceptionIfTagNameIsNull.

/**
 * @see LocationService#saveLocationTag(LocationTag)
 */
@Test(expected = APIException.class)
public void saveLocationTag_shouldThrowExceptionIfTagNameIsNull() {
    LocationTag tag = new LocationTag();
    tag.setName(null);
    tag.setDescription("desc");
    Context.getLocationService().saveLocationTag(tag);
}
Also used : LocationTag(org.openmrs.LocationTag) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 20 with LocationTag

use of org.openmrs.LocationTag in project openmrs-core by openmrs.

the class LocationTagValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.

/**
 * @see LocationTagValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
    LocationTag locationTag = new LocationTag();
    locationTag.setName("name");
    locationTag.setDescription("description");
    locationTag.setRetireReason("retireReason");
    Errors errors = new BindException(locationTag, "locationTag");
    new LocationTagValidator().validate(locationTag, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : LocationTag(org.openmrs.LocationTag) Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

LocationTag (org.openmrs.LocationTag)21 Test (org.junit.Test)17 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)16 Location (org.openmrs.Location)8 BindException (org.springframework.validation.BindException)2 Errors (org.springframework.validation.Errors)2 Criteria (org.hibernate.Criteria)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1 Patient (org.openmrs.Patient)1 PatientIdentifierType (org.openmrs.PatientIdentifierType)1 Visit (org.openmrs.Visit)1 APIException (org.openmrs.api.APIException)1 LocationService (org.openmrs.api.LocationService)1 VisitService (org.openmrs.api.VisitService)1 AdtService (org.openmrs.module.emrapi.adt.AdtService)1 LocationDescriptor (org.openmrs.module.metadatadeploy.descriptor.LocationDescriptor)1 PaperRecord (org.openmrs.module.paperrecord.PaperRecord)1 PaperRecordServiceImpl (org.openmrs.module.paperrecord.PaperRecordServiceImpl)1 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1