|
| 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.order; |
| 15 | + |
| 16 | +import static junit.framework.Assert.assertFalse; |
| 17 | +import static junit.framework.Assert.assertTrue; |
| 18 | + |
| 19 | +import org.junit.Test; |
| 20 | +import org.openmrs.OrderType; |
| 21 | + |
| 22 | +/** |
| 23 | + * Contains test for OrderUtil |
| 24 | + */ |
| 25 | +public class OrderUtilTest { |
| 26 | + |
| 27 | + /** |
| 28 | + * @verifies true if orderType2 is the same or is a subtype of orderType1 |
| 29 | + * @see OrderUtil#isType(org.openmrs.OrderType, org.openmrs.OrderType) |
| 30 | + */ |
| 31 | + @Test |
| 32 | + public void isType_shouldTrueIfOrderType2IsTheSameOrIsASubtypeOfOrderType1() throws Exception { |
| 33 | + OrderType orderType = new OrderType(); |
| 34 | + OrderType subType1 = new OrderType(); |
| 35 | + OrderType subType2 = new OrderType(); |
| 36 | + subType2.setParent(subType1); |
| 37 | + subType1.setParent(orderType); |
| 38 | + assertTrue(OrderUtil.isType(subType2, subType2)); |
| 39 | + assertTrue(OrderUtil.isType(subType1, subType2)); |
| 40 | + assertTrue(OrderUtil.isType(orderType, subType2)); |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * @verifies return false if they are both null |
| 45 | + * @see OrderUtil#isType(org.openmrs.OrderType, org.openmrs.OrderType) |
| 46 | + */ |
| 47 | + @Test |
| 48 | + public void isType_shouldReturnFalseIfTheyAreBothNull() throws Exception { |
| 49 | + assertFalse(OrderUtil.isType(null, null)); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * @verifies return false if any is null and the other is not |
| 54 | + * @see OrderUtil#isType(org.openmrs.OrderType, org.openmrs.OrderType) |
| 55 | + */ |
| 56 | + @Test |
| 57 | + public void isType_shouldReturnFalseIfAnyIsNullAndTheOtherIsNot() throws Exception { |
| 58 | + assertFalse(OrderUtil.isType(new OrderType(), null)); |
| 59 | + assertFalse(OrderUtil.isType(null, new OrderType())); |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * @verifies false if orderType2 is neither the same nor a subtype of orderType1 |
| 64 | + * @see OrderUtil#isType(org.openmrs.OrderType, org.openmrs.OrderType) |
| 65 | + */ |
| 66 | + @Test |
| 67 | + public void isType_shouldFalseIfOrderType2IsNeitherTheSameNorASubtypeOfOrderType1() throws Exception { |
| 68 | + assertFalse(OrderUtil.isType(new OrderType(), new OrderType())); |
| 69 | + } |
| 70 | +} |
0 commit comments