Package org.junithelper.core.meta

Examples of org.junithelper.core.meta.ClassMeta


    }

    @Test
    public void getNewTestCaseSourceCode_A$_JUnit4() throws Exception {
        String sourceCodeString = "package hoge.foo; import java.util.List;\r\nimport java.util.Map; public class Sample { public Sample() {}\r\n public int doSomething(String str, long longValue) throws Throwable { System.out.println(\"aaaa\"); } public void doSomething(List<Map<String, String>> nested, Map<String,Map<String,String>> nested2) { } }";
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        String actual = target.getNewTestCaseSourceCode();
        String expected = "package hoge.foo;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.HashMap;\r\nimport hoge.foo.Sample.*;\r\nimport static org.hamcrest.CoreMatchers.*;\r\nimport static org.junit.Assert.*;\r\nimport org.junit.Test;\r\n\r\nimport java.util.List;\r\nimport java.util.Map;\r\npublic class SampleTest {\r\n\r\n  @Test\r\n  public void type() throws Exception {\r\n    // TODO auto-generated by JUnit Helper.\r\n    assertThat(Sample.class, notNullValue());\r\n  }\r\n\r\n  @Test\r\n  public void instantiation() throws Exception {\r\n    // TODO auto-generated by JUnit Helper.\r\n    Sample target = new Sample();\r\n    assertThat(target, notNullValue());\r\n  }\r\n\r\n  @Test\r\n  public void doSomething_A$String$long() throws Throwable {\r\n    // TODO auto-generated by JUnit Helper.\r\n    Sample target = new Sample();\r\n    String str = null;\r\n    long longValue = 0L;\r\n    int actual = target.doSomething(str, longValue);\r\n    int expected = 0;\r\n    assertThat(actual, is(equalTo(expected)));\r\n  }\r\n\r\n  @Test\r\n  public void doSomething_A$List$Map() throws Exception {\r\n    // TODO auto-generated by JUnit Helper.\r\n    Sample target = new Sample();\r\n    List nested = new ArrayList();\r\n    Map nested2 = new HashMap();\r\n    target.doSomething(nested, nested2);\r\n  }\r\n\r\n}\r\n";
        assertEquals(expected, actual);
    }
View Full Code Here


    }

    @Test
    public void getTestCaseSourceCodeWithLackingTestMethod_A$String() throws Exception {
        String sourceCodeString = "package hoge.foo; import java.util.List; public class Sample { public Sample() {}\r\n public int doSomething(String str, long longValue) throws Throwable { System.out.println(\"aaaa\") } }";
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        String currentTestCaseSourceCode = "package hoge.foo;\r\n\r\nimport java.util.List;\r\n\r\npublic class SampleTest {\r\n\r\n}\r\n";
        String actual = target.getTestCaseSourceCodeWithLackingTestMethod(currentTestCaseSourceCode);
        String expected = "package hoge.foo;\r\n\r\nimport hoge.foo.Sample.*;\r\nimport static org.hamcrest.CoreMatchers.*;\r\nimport static org.junit.Assert.*;\r\nimport org.junit.Test;\r\n\r\nimport java.util.List;\r\n\r\npublic class SampleTest {\r\n\r\n  @Test\r\n  public void type() throws Exception {\r\n    // TODO auto-generated by JUnit Helper.\r\n    assertThat(Sample.class, notNullValue());\r\n  }\r\n\r\n  @Test\r\n  public void instantiation() throws Exception {\r\n    // TODO auto-generated by JUnit Helper.\r\n    Sample target = new Sample();\r\n    assertThat(target, notNullValue());\r\n  }\r\n\r\n  @Test\r\n  public void doSomething_A$String$long() throws Throwable {\r\n    // TODO auto-generated by JUnit Helper.\r\n    Sample target = new Sample();\r\n    String str = null;\r\n    long longValue = 0L;\r\n    int actual = target.doSomething(str, longValue);\r\n    int expected = 0;\r\n    assertThat(actual, is(equalTo(expected)));\r\n  }\r\n\r\n}\r\n";
        assertEquals(expected, actual);
View Full Code Here

    @Test
    public void getUnifiedVersionTestCaseSourceCode_A$String$JUnitVersion_toJUnit3() throws Exception {
        String currentTestCaseSourceCode = "package hoge;\r\nimport org.junit.Test;\r\n\r\npublic class SampleTest {\r\n\r\n\t@Test\r\n\tpublic void hogehoge() throws Excpetion {\r\n\t}\r\n\r\n }";
        String sourceCodeString = "package hoge.foo; import java.util.List; public class Sample { public Sample() {}\r\n public int doSomething(String str, long longValue) throws Throwable { System.out.println(\"aaaa\") } }";
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        JUnitVersion version = JUnitVersion.version3;
        String actual = target.getUnifiedVersionTestCaseSourceCode(currentTestCaseSourceCode, version);
        String expected = "package hoge;\r\n\r\nimport java.util.List;\r\nimport hoge.foo.Sample.*;\r\nimport junit.framework.TestCase;\r\nimport org.junit.Test;\r\n\r\npublic class SampleTest extends TestCase {\r\n\r\n\tpublic void test_hogehoge() throws Excpetion {\r\n\t}\r\n\r\n }";
        assertEquals(expected, actual);
View Full Code Here

    @Test
    public void getUnifiedVersionTestCaseSourceCode_A$String$JUnitVersion_toJUnit4() throws Exception {
        String currentTestCaseSourceCode = "package hoge;\r\n\r\npublic class SampleTest extends junit.framework.TestCase {\r\n\r\n\tpublic void test_hogehoge() throws Excpetion {\r\n\t}\r\n\r\n }";
        String sourceCodeString = "package hoge.foo; import java.util.List; public class Sample { public Sample() {}\r\n public int doSomething(String str, long longValue) throws Throwable { System.out.println(\"aaaa\") } }";
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        JUnitVersion version = JUnitVersion.version4;
        String actual = target.getUnifiedVersionTestCaseSourceCode(currentTestCaseSourceCode, version);
        String expected = "package hoge;\r\n\r\nimport java.util.List;\r\nimport hoge.foo.Sample.*;\r\nimport static org.hamcrest.CoreMatchers.*;\r\nimport static org.junit.Assert.*;\r\nimport org.junit.Test;\r\n\r\npublic class SampleTest {\r\n\r\n\t@Test \r\n\tpublic void hogehoge() throws Excpetion {\r\n\t}\r\n\r\n }";
        assertEquals(expected, actual);
View Full Code Here

    @Test
    public void getUnifiedVersionTestCaseSourceCode_A$String$JUnitVersion_toJUnit4_SuperClassWhenImportedTestCase()
            throws Exception {
        String currentTestCaseSourceCode = "package hoge;\r\n\r\nimport junit.framework.TestCase;\r\n\r\npublic class SampleTest extends TestCase {\r\n\r\n\tpublic void test_hogehoge() throws Excpetion {\r\n\t}\r\n\r\n }";
        String sourceCodeString = "package hoge.foo; import java.util.List; public class Sample { public Sample() {}\r\n public int doSomething(String str, long longValue) throws Throwable { System.out.println(\"aaaa\") } }";
        ClassMeta targetClassMeta = classMetaExtractor.extract(sourceCodeString);
        target.initialize(targetClassMeta);
        JUnitVersion version = JUnitVersion.version4;
        String actual = target.getUnifiedVersionTestCaseSourceCode(currentTestCaseSourceCode, version);
        String expected = "package hoge;\r\n\r\nimport java.util.List;\r\nimport hoge.foo.Sample.*;\r\nimport static org.hamcrest.CoreMatchers.*;\r\nimport static org.junit.Assert.*;\r\nimport org.junit.Test;\r\n\r\n\r\n\r\npublic class SampleTest {\r\n\r\n\t@Test \r\n\tpublic void hogehoge() throws Excpetion {\r\n\t}\r\n\r\n }";
        assertEquals(expected, actual);
View Full Code Here

    @Test
    public void appendRequiredImportListToSourceCode_A$String$ClassMeta$Configuration() throws Exception {
        TestCaseGeneratorImpl target = new TestCaseGeneratorImpl(config, lineBreakProvider);
        String sourceCode = "public class Sample {}";
        ClassMeta targetClassMeta = new ClassMeta();
        String actual = target.appendRequiredImportListToSourceCode(sourceCode, targetClassMeta, config);
        assertThat(actual, notNullValue());
    }
View Full Code Here

    @Test
    public void appendRequiredImportListToSourceCode_A$String$ClassMeta$Configuration_StringIsNull() throws Exception {
        TestCaseGeneratorImpl target = new TestCaseGeneratorImpl(config, lineBreakProvider);
        String sourceCode = null;
        ClassMeta targetClassMeta = new ClassMeta();
        try {
            target.appendRequiredImportListToSourceCode(sourceCode, targetClassMeta, config);
            fail();
        } catch (JUnitHelperCoreException e) {
        }
View Full Code Here

    @Test
    public void appendRequiredImportListToSourceCode_A$String$ClassMeta$Configuration_StringIsEmpty() throws Exception {
        TestCaseGeneratorImpl target = new TestCaseGeneratorImpl(config, lineBreakProvider);
        String sourceCode = "";
        ClassMeta targetClassMeta = new ClassMeta();
        String actual = target.appendRequiredImportListToSourceCode(sourceCode, targetClassMeta, config);
        assertThat(actual, notNullValue());
    }
View Full Code Here

    @Test
    public void isCanonicalClassNameUsed_A$String$String$ClassMeta_ImportWildCard() throws Exception {
        String expectedCanonicalClassName = "com.example.bean.SampleBean";
        String usedClassName = "SampleBean";
        ClassMeta targetClassMeta = new ClassMeta();
        targetClassMeta.importedList.add("com.example.bean.*");
        // when
        boolean actual = GeneratorImplFunction.isCanonicalClassNameUsed(expectedCanonicalClassName, usedClassName,
                targetClassMeta);
        // then
View Full Code Here

    @Test
    public void isCanonicalClassNameUsed_A$String$String$ClassMeta_Imported() throws Exception {
        String expectedCanonicalClassName = "com.example.bean.SampleBean";
        String usedClassName = "SampleBean";
        ClassMeta targetClassMeta = new ClassMeta();
        targetClassMeta.importedList.add("com.example.bean.SampleBean");
        // when
        boolean actual = GeneratorImplFunction.isCanonicalClassNameUsed(expectedCanonicalClassName, usedClassName,
                targetClassMeta);
        // then
View Full Code Here

TOP

Related Classes of org.junithelper.core.meta.ClassMeta

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.