### Question:
CommonLowerSuperTypes { public static Set<DataType> run(DataType t1, DataType t2, boolean include_base) { Ensure.not_null(t1); Ensure.not_null(t2); Set<DataType> super_1 = AllSuperTypes.run(t1, include_base); Set<DataType> super_2 = AllSuperTypes.run(t2, include_base); Set<DataType> common = new HashSet<>(super_1); common.retainAll(super_2); for (DataType t : new HashSet<>(common)) { boolean is_super_of_any = false; for (DataType c : common) { if (t.super_of(c)) { is_super_of_any = true; break; } } if (is_super_of_any) { common.remove(t); } } return common; } private  CommonLowerSuperTypes(); static Set<DataType> run(DataType t1, DataType t2, 
			boolean include_base);  }### Answer:
@Test public void same_type_not_included() throws Exception { TestDataType x = new TestDataType("x"); m_dts.add(x); Set<DataType> r = CommonLowerSuperTypes.run(x, x, false); assertEquals(0, r.size()); }
@Test public void same_type_with_included() throws Exception { TestDataType x = new TestDataType("x"); m_dts.add(x); Set<DataType> r = CommonLowerSuperTypes.run(x, x, true); assertEquals(1, r.size()); assertTrue(r.contains(x)); }
@Test public void super_and_sub_type_not_included() throws Exception { TestDataType x = new TestDataType("x"); TestDataType y = new TestDataType("y", x); m_dts.add(x); m_dts.add(y); Set<DataType> r = CommonLowerSuperTypes.run(x, y, false); assertEquals(0, r.size()); }
@Test public void super_and_sub_type_with_included() throws Exception { TestDataType x = new TestDataType("x"); TestDataType y = new TestDataType("y", x); m_dts.add(x); m_dts.add(y); Set<DataType> r = CommonLowerSuperTypes.run(x, y, true); assertEquals(1, r.size()); assertTrue(r.contains(x)); }
@Test public void two_types_with_common_super_type() throws Exception { TestDataType x = new TestDataType("x"); TestDataType y = new TestDataType("y", x); TestDataType z = new TestDataType("z", x); m_dts.add(x); m_dts.add(y); m_dts.add(z); Set<DataType> r = CommonLowerSuperTypes.run(y, z, true); assertEquals(1, r.size()); assertTrue(r.contains(x)); }
@Test public void two_types_with_two_common_super_type() throws Exception { TestDataType x = new TestDataType("x"); TestDataType y = new TestDataType("y"); TestDataType z = new TestDataType("z", x, y); TestDataType w = new TestDataType("w", x, y); m_dts.add(x); m_dts.add(y); m_dts.add(z); m_dts.add(w); Set<DataType> r = CommonLowerSuperTypes.run(w, z, true); assertEquals(2, r.size()); assertTrue(r.contains(x)); assertTrue(r.contains(y)); }
@Test public void two_types_with_two_common_related_super_types() throws Exception { TestDataType x = new TestDataType("x"); TestDataType y = new TestDataType("y", x); TestDataType z = new TestDataType("z", x, y); TestDataType w = new TestDataType("w", x, y); m_dts.add(x); m_dts.add(y); m_dts.add(z); m_dts.add(w); Set<DataType> r = CommonLowerSuperTypes.run(w, z, true); assertEquals(1, r.size()); assertTrue(r.contains(y)); }