use of org.openmrs.ConceptNameTag in project openmrs-core by openmrs.
the class ConceptServiceTest method purgeConceptNameTag_shouldDeleteTheSpecifiedConceptNameTagFromTheDatabase.
/**
* @see ConceptService#purgeConceptNameTag(ConceptNameTag)
*/
@Test
public void purgeConceptNameTag_shouldDeleteTheSpecifiedConceptNameTagFromTheDatabase() {
executeDataSet("org/openmrs/api/include/ConceptServiceTest-tags.xml");
// sanity check
ConceptNameTag nameTag = Context.getConceptService().getConceptNameTagByName("preferred_en");
Assert.assertNotNull(nameTag);
Context.getConceptService().purgeConceptNameTag(nameTag);
Assert.assertNull(Context.getConceptService().getConceptNameTagByName("preferred_en"));
}
use of org.openmrs.ConceptNameTag in project openmrs-core by openmrs.
the class ConceptServiceTest method saveConceptNameTag_shouldNotSaveAConceptNameTagIfTagExists.
@Test(expected = Exception.class)
public void saveConceptNameTag_shouldNotSaveAConceptNameTagIfTagExists() {
String tag = "a new tag";
ConceptNameTag nameTag = new ConceptNameTag();
nameTag.setTag(tag);
conceptService.saveConceptNameTag(nameTag);
ConceptNameTag secondNameTag = new ConceptNameTag();
secondNameTag.setTag(tag);
ConceptNameTag existingConceptNameTag = conceptService.saveConceptNameTag(secondNameTag);
assertNull(secondNameTag.getId());
assertEquals(existingConceptNameTag.getId(), nameTag.getId());
}
use of org.openmrs.ConceptNameTag in project openmrs-core by openmrs.
the class ConceptNameSaveHandlerTest method handle_shouldNotReplaceTagsThatHaveIds.
/**
* @see ConceptNameSaveHandler#handle(ConceptName,User,Date,String)
*/
@Test
public void handle_shouldNotReplaceTagsThatHaveIds() {
ConceptNameSaveHandler handler = new ConceptNameSaveHandler();
ConceptName name = new ConceptName();
ConceptNameTag tag = new ConceptNameTag("some randome tag name with an id", "");
// this tag has an id
tag.setConceptNameTagId(34);
name.addTag(tag);
handler.handle(name, null, null, null);
ConceptNameTag newTag = name.getTags().iterator().next();
Assert.assertEquals(34, newTag.getConceptNameTagId().intValue());
}
use of org.openmrs.ConceptNameTag in project openmrs-core by openmrs.
the class ConceptNameSaveHandlerTest method handle_shouldReplaceTagsWithoutIdsWithDatabaseFetchedTag.
/**
* @see ConceptNameSaveHandler#handle(ConceptName,User,Date,String)
*/
@Test
public void handle_shouldReplaceTagsWithoutIdsWithDatabaseFetchedTag() {
ConceptNameSaveHandler handler = new ConceptNameSaveHandler();
ConceptName name = new ConceptName();
// this tag has a null id
name.addTag("preferred");
// this tag has a null id
name.addTag("short");
handler.handle(name, null, null, null);
for (ConceptNameTag tag : name.getTags()) {
if (tag.getTag().equals("preferred")) {
Assert.assertEquals(4, tag.getConceptNameTagId().intValue());
} else if (tag.getTag().equals("short")) {
Assert.assertEquals(2, tag.getConceptNameTagId().intValue());
}
}
}
use of org.openmrs.ConceptNameTag in project openmrs-core by openmrs.
the class ConceptNameSaveHandlerTest method handle_shouldNotReplaceTagsWithoutIdsThatAreNotInTheDatabase.
/**
* @see ConceptNameSaveHandler#handle(ConceptName,User,Date,String)
*/
@Test
public void handle_shouldNotReplaceTagsWithoutIdsThatAreNotInTheDatabase() {
ConceptNameSaveHandler handler = new ConceptNameSaveHandler();
ConceptName name = new ConceptName();
// this tag has a null id
name.addTag(new ConceptNameTag("Some randome tag name", ""));
handler.handle(name, null, null, null);
ConceptNameTag newTag = name.getTags().iterator().next();
Assert.assertNull(newTag.getConceptNameTagId());
}
Aggregations