### Question:
OrderUtil { public static boolean isType(OrderType orderType1, OrderType orderType2) { if (orderType1 != null && orderType2 != null) { if (orderType2.equals(orderType1)) { return true; } OrderType parentType = orderType2.getParent(); while (parentType != null) { if (parentType.equals(orderType1)) { return true; } parentType = parentType.getParent(); } } return false; } private  OrderUtil(); static boolean isType(OrderType orderType1, OrderType orderType2); static boolean checkScheduleOverlap(Order order1, Order order2);  }### Answer:
@Test public void isType_shouldTrueIfOrderType2IsTheSameOrIsASubtypeOfOrderType1() { OrderType orderType = new OrderType(); OrderType subType1 = new OrderType(); OrderType subType2 = new OrderType(); subType2.setParent(subType1); subType1.setParent(orderType); assertTrue(OrderUtil.isType(subType2, subType2)); assertTrue(OrderUtil.isType(subType1, subType2)); assertTrue(OrderUtil.isType(orderType, subType2)); }
@Test public void isType_shouldReturnFalseIfTheyAreBothNull() { assertFalse(OrderUtil.isType(null, null)); }
@Test public void isType_shouldReturnFalseIfAnyIsNullAndTheOtherIsNot() { assertFalse(OrderUtil.isType(new OrderType(), null)); assertFalse(OrderUtil.isType(null, new OrderType())); }
@Test public void isType_shouldFalseIfOrderType2IsNeitherTheSameNorASubtypeOfOrderType1() { assertFalse(OrderUtil.isType(new OrderType(), new OrderType())); }