diff options
Diffstat (limited to 'plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers')
5 files changed, 46 insertions, 48 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/OutlineResolutionAndNumberTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/OutlineResolutionAndNumberTest.java index 69c199c399f..021fbdcc751 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/OutlineResolutionAndNumberTest.java +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/OutlineResolutionAndNumberTest.java @@ -14,17 +14,17 @@ import org.junit.Assert; import org.junit.Test; /** + * Asserting true in general means GUI should be called for user to make decision; false - opposite + * * @author Karol M. Wilk */ public final class OutlineResolutionAndNumberTest { + //TODO: change to parameterized type test + private static final String LAST_OUTLINE_NUMBER = "3.1.1.2.1.7"; /* realistic outline number */ private final OutlineResolution outlineResolution = new OutlineResolution(); - /** - * ! Asserting true in general means GUI should be called for user to make decision; false - opposite - */ - @Test public void testLowerOutlineNumbers() { Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("3.1.1.2.1.6", LAST_OUTLINE_NUMBER)); @@ -36,6 +36,7 @@ public final class OutlineResolutionAndNumberTest { Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("2.10", LAST_OUTLINE_NUMBER)); Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("2.1", LAST_OUTLINE_NUMBER)); Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("1.8", LAST_OUTLINE_NUMBER)); + Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("0.15", LAST_OUTLINE_NUMBER)); } @Test @@ -49,14 +50,16 @@ public final class OutlineResolutionAndNumberTest { } @Test + public void testZeroBasedOutlineNumbers() { + Assert.assertFalse(outlineResolution.isInvalidOutlineNumber("3.2.1.0.1", "3.2.1")); + Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("3.2.0.0.1", "3.2.1")); + } + + @Test public void testRandomOutlineNumbers() { Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("6.5", LAST_OUTLINE_NUMBER)); Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("0.25", LAST_OUTLINE_NUMBER)); Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("10.48", LAST_OUTLINE_NUMBER)); - Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("-5.6", LAST_OUTLINE_NUMBER)); - Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("34.fin3bbtb34fm34", LAST_OUTLINE_NUMBER)); - Assert.assertFalse(outlineResolution.isInvalidOutlineNumber("", "")); - Assert.assertFalse(outlineResolution.isInvalidOutlineNumber(null, null)); Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("200.12.3", LAST_OUTLINE_NUMBER)); Assert.assertFalse(outlineResolution.isInvalidOutlineNumber("4.0", "3.1")); Assert.assertFalse(outlineResolution.isInvalidOutlineNumber("2.1.1.1.2", "2.1.1.1.1")); @@ -66,7 +69,5 @@ public final class OutlineResolutionAndNumberTest { Assert.assertFalse(outlineResolution.isInvalidOutlineNumber("2.2", "2.1.1.1.1")); Assert.assertFalse(outlineResolution.isInvalidOutlineNumber("2.1.2", "2.1.1.1.1")); Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("3.2", "2.1.1.1.1")); - Assert.assertTrue(outlineResolution.isInvalidOutlineNumber("b", "c")); } - } diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordOutlineTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordOutlineTest.java index 032b6329d7f..baa5aa9822e 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordOutlineTest.java +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordOutlineTest.java @@ -17,7 +17,6 @@ import java.util.Collection; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; - import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.jdk.core.util.ReservedCharacters; import org.eclipse.osee.framework.jdk.core.util.Strings; @@ -54,50 +53,28 @@ public final class WordOutlineTest { this.expectedData = expectedData; } - //@formatter:off /** - * Note: some of the data objects need to repeat data - * from previous test because they are considered to - * be lastHeaderNumber or lastHeaderName or lastContent - * - * @return collection of data sets used as input for parameterized unit test - */ + * Note: some of the data objects need to repeat data from previous test because they are considered to be + * lastHeaderNumber or lastHeaderName or lastContent + * + * @return collection of data sets used as input for parameterized unit test + */ @Parameters public static Collection<Object[]> getData() { List<Object[]> data = new ArrayList<Object[]>(); - addTest(data, OUTLINE_WITH_NUMBER, data("1.", "Outline TITLE", "")); - addTest(data, OUTLINE_WITH_NUMBER_AND_CONTENT, data("5.", "SCOPE", ""), data("5.", "SCOPE", "content content content more content")); - + addTest(data, OUTLINE_WITH_NUMBER, data("1.0", "Outline TITLE", "")); + addTest(data, OUTLINE_WITH_NUMBER_AND_CONTENT, data("5.0", "SCOPE", ""), + data("5.0", "SCOPE", "content content content more content")); + StringBuilder builder = new StringBuilder(); builder.append("This 1.6 is some interesting content 2.3SAMPL"); builder.append(ReservedCharacters.toCharacter("â")); builder.append(ReservedCharacters.toCharacter("€")); builder.append(ReservedCharacters.toCharacter("“")); builder.append("10."); - - addTest(data, NUMBER_EMBED_IN_CONTENT, data("1.", "SCOPE", ""), data("1.", "SCOPE", builder.toString())); - return data; - } - //@formatter:on - - private static void addTest(List<Object[]> data, String dataFileName, DelegateData... expectedData) { - data.add(new Object[] {dataFileName, expectedData}); - } - - private static DelegateData data(String headerNumber, String headerName, String content) { - return new DelegateData(headerNumber, headerName, content); - } - private static String getResourceData(String name) throws IOException { - InputStream inputStream = null; - try { - inputStream = WordOutlineTest.class.getResourceAsStream(name); - String data = Lib.inputStreamToString(inputStream); - Assert.assertTrue(Strings.isValid(data)); - return data; - } finally { - Lib.close(inputStream); - } + addTest(data, NUMBER_EMBED_IN_CONTENT, data("1.0", "SCOPE", ""), data("1.0", "SCOPE", builder.toString())); + return data; } @Test @@ -146,13 +123,33 @@ public final class WordOutlineTest { Assert.assertNull(delegate.getLastContent()); } + private static void addTest(List<Object[]> data, String dataFileName, DelegateData... expectedData) { + data.add(new Object[] {dataFileName, expectedData}); + } + + private static DelegateData data(String headerNumber, String headerName, String content) { + return new DelegateData(headerNumber, headerName, content); + } + + private static String getResourceData(String name) throws IOException { + InputStream inputStream = null; + String data; + try { + inputStream = WordOutlineTest.class.getResourceAsStream(name); + data = Lib.inputStreamToString(inputStream); + Assert.assertTrue(Strings.isValid(data)); + } finally { + Lib.close(inputStream); + } + return data; + } + private static final class DelegateData { private final String headerNumber; private final String headerName; private final String content; public DelegateData(String headerNumber, String headerName, String content) { - super(); this.headerNumber = headerNumber; this.headerName = headerName; this.content = content; diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/numberEmbeddedInTheContent.xml b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/numberEmbeddedInTheContent.xml index e8bdce1050d..acb720890dc 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/numberEmbeddedInTheContent.xml +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/numberEmbeddedInTheContent.xml @@ -1,2 +1,2 @@ -<w:p wsp:rsidR="00AC5806" wsp:rsidRDefault="00A6010B"><w:pPr><w:pStyle w:val="lvl2on"/><w:spacing w:before="8" w:line="273" w:line-rule="at-least"/></w:pPr><w:r><w:rPr><w:b/><w:b-cs/><w:caps/></w:rPr><w:t>1. SCOPE</w:t></w:r></w:p> +<w:p wsp:rsidR="00AC5806" wsp:rsidRDefault="00A6010B"><w:pPr><w:pStyle w:val="lvl2on"/><w:spacing w:before="8" w:line="273" w:line-rule="at-least"/></w:pPr><w:r><w:rPr><w:b/><w:b-cs/><w:caps/></w:rPr><w:t>1.0 SCOPE</w:t></w:r></w:p> <w:p wsp:rsidR="00sC5806" wsp:rsidRDefault="00A6010B"><w:pPr><w:pStyle w:val="Ltxt"/><w:spacing w:before="48" w:line="273" w:line-rule="at-least"/></w:pPr><w:r><w:t>This 1.6 is some interesting content 2.3</w:t></w:r><w:r wsp:rsidR="00DC3082"><w:fldChar w:fldCharType="begin"/></w:r><w:r><w:instrText>fe "SAMPL-10"</w:instrText></w:r><w:r wsp:rsidR="00DC3082"><w:fldChar w:fldCharType="end"/></w:r><w:r><w:t>SAMPL–10.</w:t></w:r></w:p> diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/outlineNameNumberAndContent.xml b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/outlineNameNumberAndContent.xml index b6b22c2e785..cfa26a9a6f0 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/outlineNameNumberAndContent.xml +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/outlineNameNumberAndContent.xml @@ -1,2 +1,2 @@ -<w:p wsp:rsidR="00AC5806" wsp:rsidRDefault="00A6010B"><w:pPr><w:pStyle w:val="lvl2on"/><w:spacing w:before="8" w:line="273" w:line-rule="at-least"/></w:pPr><w:r><w:rPr><w:b/><w:b-cs/><w:caps/></w:rPr><w:t>5. SCOPE</w:t></w:r></w:p> +<w:p wsp:rsidR="00AC5806" wsp:rsidRDefault="00A6010B"><w:pPr><w:pStyle w:val="lvl2on"/><w:spacing w:before="8" w:line="273" w:line-rule="at-least"/></w:pPr><w:r><w:rPr><w:b/><w:b-cs/><w:caps/></w:rPr><w:t>5.0 SCOPE</w:t></w:r></w:p> <w:p wsp:rsidR="00As5806" wsp:rsidRDefault="00A6010B"><w:pPr><w:pStyle w:val="Ltxt"/><w:spacing w:before="48" w:line="273" w:line-rule="at-least"/></w:pPr><w:r><w:t>content content content</w:t></w:r><w:r wsp:rsidR="00DC3082"><w:fldChar w:fldCharType="begin"/></w:r><w:r><w:instrText>blah</w:instrText></w:r><w:r wsp:rsidR="00DC3082"><w:fldChar w:fldCharType="end"/></w:r><w:r><w:t> more content</w:t></w:r></w:p> diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/outlineNameWithNumber.xml b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/outlineNameWithNumber.xml index d5a27b1bf6c..5c33ebad72a 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/outlineNameWithNumber.xml +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/outlineNameWithNumber.xml @@ -1 +1 @@ -<w:p wsp:rsidR="00s5806" wsp:rsidRDefault="00A6010B"><w:pPr><w:pStyle w:val="lvl2on"/><w:spacing w:before="8" w:line="273" w:line-rule="at-least"/></w:pPr><w:r><w:rPr><w:b/><w:b-cs/><w:caps/></w:rPr><w:t>1. Outline TITLE </w:t></w:r></w:p> +<w:p wsp:rsidR="00s5806" wsp:rsidRDefault="00A6010B"><w:pPr><w:pStyle w:val="lvl2on"/><w:spacing w:before="8" w:line="273" w:line-rule="at-least"/></w:pPr><w:r><w:rPr><w:b/><w:b-cs/><w:caps/></w:rPr><w:t>1.0 Outline TITLE </w:t></w:r></w:p> |