### Question:
XmlProcessorElement { public void process( @Nonnull final XmlParser xmlParser, @Nonnull final XmlType xmlTypeParent) throws Exception { if (elementOccurs.equals(OccursEnum.required)) { elementProcessor.parentLinkSet(xmlTypeParent, elementName); xmlParser.required(elementName, elementProcessor); } else if (elementOccurs.equals(OccursEnum.oneOrMore)) { elementProcessor.parentLinkAdd(xmlTypeParent, elementName); xmlParser.oneOrMore(elementName, elementProcessor); } else if (elementOccurs.equals(OccursEnum.optional)) { elementProcessor.parentLinkSet(xmlTypeParent, elementName); xmlParser.optional(elementName, elementProcessor); } else if (elementOccurs.equals(OccursEnum.zeroOrMore)) { elementProcessor.parentLinkAdd(xmlTypeParent, elementName); xmlParser.zeroOrMore(elementName, elementProcessor); } } XmlProcessorElement(
      @Nonnull final XmlProcessorType elementProcessorParam,
      @Nonnull final String elementNameParam,
      @Nonnull final OccursEnum elementOccursParam); void process(
      @Nonnull final XmlParser xmlParser,
      @Nonnull final XmlType xmlTypeParent); void processSubstGroup(
      @Nonnull final XmlParser xmlParser,
      @Nonnull final XmlType xmlTypeParent,
      @Nonnull final Attributes attributes);  }### Answer:
@Test public void testOccuresRequired() throws Exception { xmlParserMock.required("name", xmlElementProcessorMock); replay(xmlParserMock); XmlType parent = createMock(XmlType.class); replay(parent); xmlElementProcessorMock.parentLinkSet(parent, "name"); replay(xmlElementProcessorMock); XmlProcessorElement child = new XmlProcessorElement(xmlElementProcessorMock, "name", OccursEnum.required); child.process(xmlParserMock, parent); verify(parent); }
@Test public void testOccuresOneOrMore() throws Exception { xmlParserMock.oneOrMore("name", xmlElementProcessorMock); replay(xmlParserMock); XmlType parent = createMock(XmlType.class); replay(parent); xmlElementProcessorMock.parentLinkAdd(parent, "name"); replay(xmlElementProcessorMock); XmlProcessorElement child = new XmlProcessorElement(xmlElementProcessorMock, "name", OccursEnum.oneOrMore); child.process(xmlParserMock, parent); verify(parent); }
@Test public void testOccuresOptional() throws Exception { xmlParserMock.optional("name", xmlElementProcessorMock); replay(xmlParserMock); XmlType parent = createMock(XmlType.class); replay(parent); xmlElementProcessorMock.parentLinkSet(parent, "name"); replay(xmlElementProcessorMock); XmlProcessorElement child = new XmlProcessorElement(xmlElementProcessorMock, "name", OccursEnum.optional); child.process(xmlParserMock, parent); verify(parent); }
@Test public void testOccuresZeroOrMore() throws Exception { xmlParserMock.zeroOrMore("name", xmlElementProcessorMock); replay(xmlParserMock); XmlType parent = createMock(XmlType.class); replay(parent); xmlElementProcessorMock.parentLinkAdd(parent, "name"); replay(xmlElementProcessorMock); XmlProcessorElement child = new XmlProcessorElement(xmlElementProcessorMock, "name", OccursEnum.zeroOrMore); child.process(xmlParserMock, parent); verify(parent); }