### Question:
Document2004 implements IDocument, IElement { @Override public String getContent() { if(hasBeenCalledBefore ){ return txt.toString(); }else{ hasBeenCalledBefore = true; } txt.append(this.getUri()); txt.append(getDocumentHead()); txt.append(this.getBody().getContent()); txt.append("\n</w:wordDocument>"); String finalString = setUpPageOrientation(txt.toString()); return finalString; }  @Override String getContent(); @Override void setPageOrientationLandscape(); @Override IBody getBody(); @Override IFooter getFooter(); @Override IHeader getHeader(); @Override void addEle(IElement e); @Override void addEle(String str); @Override String toString(); @Override Document2004 title(String title); @Override Document2004 subject(String subject); @Override Document2004 keywords(String keywords); @Override Document2004 description(String description); @Override Document2004 category(String category); @Override Document2004 author(String author); @Override Document2004 lastAuthor(String lastAuthor); @Override Document2004 manager(String manager); @Override Document2004 company(String company); @Override Document2004 encoding(Encoding encoding); @Override Document2004 encoding(String encoding); @Override String getUri(); static final String DocumentHead; }### Answer:
@Test public void sanityTest() { IDocument myDoc = new Document2004(); assertEquals(myDoc.getContent(), myDoc.getContent()); assertEquals(myDoc.getContent(), myDoc.getContent()); }
@Test public void testDocHeadWithDefaults() { IDocument myDoc = new Document2004(); assertEquals(2, TestUtils.regexCount(myDoc.getContent(), "<*o:DocumentProperties>")); assertEquals(2, TestUtils.regexCount(myDoc.getContent(), "<*w:fonts>")); assertEquals(2, TestUtils.regexCount(myDoc.getContent(), "<*w:styles>")); assertEquals(2, TestUtils.regexCount(myDoc.getContent(), "<*w:docPr>")); assertEquals(1, TestUtils.regexCount(myDoc.getContent(), "<w:view w:val=\"print\"/>")); assertEquals(1, TestUtils.regexCount(myDoc.getContent(), "<o:Title>Java2word title</o:Title>")); assertEquals(1, TestUtils.regexCount(myDoc.getContent(), "<o:Subject>Created by Java2word library</o:Subject>")); assertEquals(1, TestUtils.regexCount(myDoc.getContent(), "<o:Keywords>java2word, word document</o:Keywords>")); assertEquals(1, TestUtils.regexCount(myDoc.getContent(), "<o:Description></o:Description>")); assertEquals(1, TestUtils.regexCount(myDoc.getContent(), "<o:Category></o:Category>")); assertEquals(1, TestUtils.regexCount(myDoc.getContent(), "<o:Author>Leonardo Correa</o:Author>")); assertEquals(1, TestUtils.regexCount(myDoc.getContent(), "<o:LastAuthor>Leonardo Correa</o:LastAuthor>")); assertEquals(1, TestUtils.regexCount(myDoc.getContent(), "<o:Manager>Leonardo Correa</o:Manager>")); assertEquals(1, TestUtils.regexCount(myDoc.getContent(), "<o:Company>Java2word, coding for fun!</o:Company>")); }
@Test public void testHead() { IDocument myDoc = new Document2004(); assertTrue(myDoc.getContent().contains("<w:docPr>")); assertTrue(myDoc.getContent() .contains("<w:view w:val=\"print\"/>")); assertTrue(myDoc.getContent() .contains("<w:zoom w:percent=\"100\"/>")); assertTrue(myDoc.getContent().contains("</w:docPr>")); }
@Test public void testPageOrientationDefault() { IDocument doc = new Document2004(); assertEquals(0, TestUtils.regexCount(doc.getContent(), "landscape")); }