/**
* @see ConceptService#getConceptByNameOrIdOrMap(String)
*/
@Test
public void getConceptByNameOrIdOrMap_shouldFindAConceptByItsConceptId() {
String id = "3";
executeDataSet(GET_CONCEPTS_BY_SET_XML);
Assert.assertEquals("3", conceptService.getConceptByNameOrIdOrMap(id).getConceptId().toString());
}
/**
* @see ConceptService#getConceptByNameOrIdOrMap(String)
*/
@Test
public void getConceptByNameOrIdOrMap_shouldGetConceptByName() {
String nameToFetch = "Some non numeric concept name";
executeDataSet(INITIAL_CONCEPTS_XML);
Concept conceptByName = conceptService.getConceptByNameOrIdOrMap(nameToFetch);
assertEquals("Unable to fetch concept by name", 1, conceptByName.getId().intValue());
}
/**
* @see ConceptService#getConceptByNameOrIdOrMap(String)
*/
@Test
public void getConceptByNameOrIdOrMap_shouldFindAConceptByItsMapping() {
String mapping = "XIC:2345";
executeDataSet(INITIAL_CONCEPTS_XML);
Concept concept = conceptService.getConceptByNameOrIdOrMap(mapping);
Assert.assertEquals("Unable to fetch concept by map", 5, concept.getId().intValue());
}
/**
* @see ConceptService#getConceptByNameOrIdOrMap(String)
*/
@Test
public void getConceptByNameOrIdOrMap_shouldFindAConceptByItsUuid() {
String uniqueId = "0ade2ed3-cd5f-4f46-9459-26127c9265ab";
executeDataSet(INITIAL_CONCEPTS_XML);
Assert.assertEquals(uniqueId, conceptService.getConceptByNameOrIdOrMap(uniqueId).getUuid());
}
/**
* @see ConceptService#getConceptByNameOrIdOrMap(String)
*/
@Test
public void getConceptByNameOrIdOrMap_shouldFindAConceptWithNonStandardUuid() {
String nonStandId = "1000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
executeDataSet(INITIAL_CONCEPTS_XML);
Assert.assertEquals(nonStandId, conceptService.getConceptByNameOrIdOrMap(nonStandId).getUuid());
}
/**
* @see ConceptService#getConceptByNameOrIdOrMap(String)
*/
@Test
public void getConceptByNameOrIdOrMap_shouldNotFindAConceptWithInvalidUuid() {
String invalidUuid = "1000";
executeDataSet(INITIAL_CONCEPTS_XML);
Assert.assertNull(conceptService.getConceptByNameOrIdOrMap(invalidUuid));
}
/**
* @see ConceptService#getConceptByNameOrIdOrMap(String)
*/
@Test
public void getConceptByNameOrIdOrMap_shouldFindAConceptByStaticConstant() {
assertThat(conceptService.getConceptByNameOrIdOrMap("org.openmrs.api.ConceptServiceTest.TEST_CONCEPT_CONSTANT_ID"), notNullValue());
assertThat(conceptService.getConceptByNameOrIdOrMap("org.openmrs.api.ConceptServiceTest.TEST_CONCEPT_CONSTANT_UUID"), notNullValue());
assertThat(conceptService.getConceptByNameOrIdOrMap("org.openmrs.api.ConceptServiceTest.TEST_CONCEPT_CONSTANT_MAPPING"), notNullValue());
}
/**
* @see ConceptService#getConceptByNameOrIdOrMap(String)
*/
@Test
public void getConceptByNameOrIdOrMap_shouldReturnNullOtherwise() {
executeDataSet(INITIAL_CONCEPTS_XML);
String conceptRef = null;
Assert.assertNull(conceptService.getConceptByNameOrIdOrMap(conceptRef));
conceptRef = "";
Assert.assertNull(conceptService.getConceptByNameOrIdOrMap(conceptRef));
conceptRef = "name does not exist in initialConcepts";
Assert.assertNull(conceptService.getConceptByNameOrIdOrMap(conceptRef));
}
that is the unit tests i managed to add the method getConceptByNameOrIdOrMap(String)