import static javax.management.ImmutableDescriptor.EMPTY_DESCRIPTOR;
import javax.management.modelmbean.DescriptorSupport;
public class UnionTest {
public static void main(String[] args) throws Exception {
ImmutableDescriptor immutableEmpty = new ImmutableDescriptor();
DescriptorSupport mutableEmpty = new DescriptorSupport();
checkEmpty(union());
checkEmpty(union(immutableEmpty));
checkEmpty(union(mutableEmpty));
checkEmpty(union(EMPTY_DESCRIPTOR, immutableEmpty, mutableEmpty));
checkEmpty(union(null, immutableEmpty, null));
ImmutableDescriptor immutableNumbers =
new ImmutableDescriptor(new String[] {"one", "two", "three"},
new Object[] {1, 2, 3});
final String[] noNames = null;
DescriptorSupport mutableNumbers =
new DescriptorSupport(immutableNumbers.getFieldNames(),
immutableNumbers.getFieldValues(noNames));
ImmutableDescriptor immutableOne =
new ImmutableDescriptor(Collections.singletonMap("one", 1));
DescriptorSupport mutableOne =
new DescriptorSupport(new String[] {"one"}, new Object[] {1});
ImmutableDescriptor immutableTwo =
new ImmutableDescriptor(Collections.singletonMap("two", 2));
DescriptorSupport mutableTwo =
new DescriptorSupport(new String[] {"two"}, new Object[] {2});
ImmutableDescriptor immutableOneTwo =
new ImmutableDescriptor(new String[] {"one", "two"},
new Object[] {1, 2});
checkEqual(union(immutableNumbers), immutableNumbers);
checkEqual(union(immutableNumbers, mutableNumbers), immutableNumbers);