package org.simpleframework.xml.core;

import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementUnion;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.ValidationTestCase;

public class UnionRequiredTest extends ValidationTestCase {

   @Root
   public static class Example {
      
      @ElementUnion({
         @Element(name="double", type=Double.class, required=false),
         @Element(name="string", type=String.class, required=true),
         @Element(name="int", type=Integer.class, required=true)
      })
      private Object value;
   }
   
   public void testRequired() throws Exception {
      Persister persister = new Persister();
      Example example = new Example();
      example.value = "test";
      boolean failure = false;
      try {
         persister.write(example, System.out);
      }catch(Exception e) {
         e.printStackTrace();
         failure = true;
      }
      assertTrue("Requirement did not match", failure);
   }
}

@@ -45,39 +45,191 @@
 ort 
-org.simpleframework.xml.Element
+java.util.Collections;%0D%0Aimport java.util.List;%0D%0A%0D%0Aimport org.simpleframework.xml.Element;%0D%0Aimport org.simpleframework.xml.ElementList;%0D%0Aimport org.simpleframework.xml.ElementListUnion
 ;%0D%0Ai
@@ -758,16 +758,372 @@
 %7D%0D%0A   %0D%0A
+   @Root%0D%0A   public static class ExampleList %7B%0D%0A      %0D%0A      @ElementListUnion(%7B%0D%0A         @ElementList(name=%22double%22, type=Double.class, required=false),%0D%0A         @ElementList(name=%22string%22, type=String.class, required=true),%0D%0A         @ElementList(name=%22int%22, type=Integer.class, required=true)%0D%0A      %7D)%0D%0A      private List%3CObject%3E value;%0D%0A   %7D%0D%0A   %0D%0A
    publi
@@ -1532,11 +1532,482 @@
 %0D%0A   %7D%0D%0A
+   %0D%0A   public void testListRequired() throws Exception %7B%0D%0A      Persister persister = new Persister();%0D%0A      ExampleList example = new ExampleList();%0D%0A      example.value = Collections.singletonList((Object)%22test%22);%0D%0A      boolean failure = false;%0D%0A      try %7B%0D%0A         persister.write(example, System.out);%0D%0A      %7Dcatch(Exception e) %7B%0D%0A         e.printStackTrace();%0D%0A         failure = true;%0D%0A      %7D%0D%0A      assertTrue(%22Requirement did not match%22, failure); %0D%0A   %7D%0D%0A
 %7D%0D%0A

Update requirment test