Skip to content

Commit

Permalink
GCI-322 - Write tests for ConceptServiceImpl.saveConceptProposal (ope…
Browse files Browse the repository at this point in the history
  • Loading branch information
PermissionError authored and dkayiwa committed Dec 9, 2019
1 parent c24475b commit 28f92b8
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions api/src/test/java/org/openmrs/api/impl/ConceptServiceImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -791,4 +791,41 @@ public void getCountOfDrugs_shouldReturnTheTotalNumberOfMatchingNumbers() {
assertEquals(new Integer(1),
conceptService.getCountOfDrugs(phrase, conceptService.getConcept(conceptId), true, true, true));
}

/**
* @see ConceptServiceImpl#saveConceptProposal(ConceptProposal)
*/
@Test
public void saveConceptProposal_shouldReturnSavedConceptProposalObject() {
final String ORIGINAL_TEXT = "OriginalText";
ConceptProposal conceptProposal = new ConceptProposal();
conceptProposal.setOriginalText(ORIGINAL_TEXT);
List<ConceptProposal> existingConceptProposals = conceptService.getConceptProposals(ORIGINAL_TEXT);
assertTrue(existingConceptProposals.isEmpty());
ConceptProposal savedConceptProposal = conceptService.saveConceptProposal(conceptProposal);
assertEquals(ORIGINAL_TEXT, savedConceptProposal.getOriginalText());
assertEquals(conceptProposal, savedConceptProposal);
}

/**
* @see ConceptServiceImpl#saveConceptProposal(ConceptProposal)
*/
@Test
public void saveConceptProposal_shouldReturnUpdatedConceptProposalObject() {
ConceptProposal conceptProposal = new ConceptProposal();
conceptProposal.setOriginalText("OriginalText");
ConceptProposal savedConceptProposal = conceptService.saveConceptProposal(conceptProposal);
final String ANOTHER_ORIGINAL_TEXT = "AnotherOriginalText";
savedConceptProposal.setOriginalText(ANOTHER_ORIGINAL_TEXT);
ConceptProposal updatedConceptProposal = conceptService.saveConceptProposal(savedConceptProposal);
assertEquals(ANOTHER_ORIGINAL_TEXT, updatedConceptProposal.getOriginalText());
}

/**
* @see ConceptServiceImpl#saveConceptProposal(ConceptProposal)
*/
@Test(expected = IllegalArgumentException.class)
public void saveConceptProposal_shouldFailGivenNull() {
conceptService.saveConceptProposal(null);
}
}

0 comments on commit 28f92b8

Please sign in to comment.