Advertisement
k-joseph

Untitled

Oct 28th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. /**
  2. * The contents of this file are subject to the OpenMRS Public License
  3. * Version 1.0 (the "License"); you may not use this file except in
  4. * compliance with the License. You may obtain a copy of the License at
  5. * http://license.openmrs.org
  6. *
  7. * Software distributed under the License is distributed on an "AS IS"
  8. * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  9. * License for the specific language governing rights and limitations
  10. * under the License.
  11. *
  12. * Copyright (C) OpenMRS, LLC. All Rights Reserved.
  13. */
  14. package org.openmrs;
  15.  
  16. import org.junit.Assert;
  17. import org.junit.Test;
  18. import org.openmrs.api.ConceptService;
  19. import org.openmrs.api.context.Context;
  20. import org.openmrs.test.Verifies;
  21.  
  22. /**
  23. * Tests the {@link ConceptNumeric} object
  24. */
  25. public class ConceptNumericTest {
  26.  
  27. /**
  28. * Regression test for TRUNK-82 (old TRAC-1511)
  29. *
  30. * @see {@link ConceptNumeric#equals(Object)}
  31. */
  32. @Test
  33. @Verifies(value = "should not return true if obj is concept", method = "equals(Object)")
  34. public void equals_shouldNotReturnTrueIfObjIsConcept() throws Exception {
  35. ConceptNumeric cn = new ConceptNumeric(123);
  36. Concept c = new Concept(123);
  37.  
  38. Assert.assertNotSame(c, cn);
  39. Assert.assertNotSame(cn, c);
  40. }
  41.  
  42. /**
  43. * saving a new existing concept with a
  44. * display_precision field and confirm it gets saved correctly
  45. */
  46. @Test
  47. public void saveANewConceptWithADisplayPrecisionField() throws Exception {
  48. ConceptNumeric conceptNumeric = new ConceptNumeric();
  49. conceptNumeric.setDisplayPrecision(32);
  50. //concept_id="5089" hi_normal="250.0" low_critical="0.0" units="kg" precise="true"
  51. conceptNumeric.setConceptId(6324);
  52. ConceptService conceptService = Context.getConceptService();
  53.  
  54. Assert.assertNotNull(conceptService.getConceptNumeric(6324).getDisplayPrecision());
  55.  
  56. conceptService.saveConcept(conceptNumeric);
  57. }
  58.  
  59. /**
  60. * updating an existing concept with a
  61. * display_precision field and confirm it gets saved correctly
  62. */
  63. @Test
  64. public void upDateAnExisitingConceptConceptWithADisplayPrecisionField() throws Exception {
  65. ConceptNumeric conceptNumeric = Context.getConceptService().getConceptNumeric(5497);
  66.  
  67. conceptNumeric.setDisplayPrecision(33);
  68. ConceptService conceptService = Context.getConceptService();
  69.  
  70. Assert.assertNotNull(conceptService.getConceptNumeric(5497).getDisplayPrecision());
  71.  
  72. conceptService.saveConcept(conceptNumeric);
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement