Package com.pogofish.jadt.sink

Examples of com.pogofish.jadt.sink.StringSink


     */
    @Test
    public void testFactory() {
        final Constructor constructor = new Constructor(Util.list(_JavaDocComment("/**", list(_JDWhiteSpace(" "), _JDWord("hello"), _JDWhiteSpace(" ")), Util.<JDTagSection>list(), "*/")), "Foo", list(new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("String", Util.<RefType>list())), "um"), new Arg(Util.<ArgModifier>list(), _Primitive(_IntType()), "yeah")));

        final StringSink sink = new StringSink("test");
        try {
            final ConstructorEmitter emitter = new StandardConstructorEmitter(new DummyClassBodyEmitter());

            emitter.constructorFactory(sink, "SomeDataType", Util.<String>list(), constructor);
        } finally {
            sink.close();
        }
        assertEquals(FACTORY, sink.result());
    }
View Full Code Here


     */
    @Test
    public void testConstrucorDeclaration() {
        final Constructor constructor = new Constructor(Util.list(_JavaDocComment("/**", list(_JDWhiteSpace(" "), _JDWord("hello"), _JDWhiteSpace(" ")), Util.<JDTagSection>list(), "*/")), "Foo", list(new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("String", Util.<RefType>list())), "um"), new Arg(Util.<ArgModifier>list(), _Primitive(_IntType()), "yeah")));

        final StringSink sink = new StringSink("test");
        try {
            final ConstructorEmitter emitter = new StandardConstructorEmitter(new DummyClassBodyEmitter());

            emitter.constructorDeclaration(sink, constructor, "NonPrimitive", Util.<String>list());
        } finally {
            sink.close();
        }
        assertEquals(CONSTRUCTOR_CLASS, sink.result());
    }
View Full Code Here

    /**
     * Make sure non parameterized type names are handled properly
     */
    public void testNonParameterizedTypeName() {
        final StringSink sink = new StringSink("test");
        try {
            emitter.emitParameterizedTypeName(sink, Util.<String>list());
        } finally {
            sink.close();           
        }
        assertEquals("", sink.result());
    }
View Full Code Here

   
    /**
     * Make sure parameterized type names with one type parameter are handled properly
     */
    public void testOneParameterizedTypeName() {
        final StringSink sink = new StringSink("test");
        try {
            emitter.emitParameterizedTypeName(sink, list("A"));
        } finally {
            sink.close();           
        }
        assertEquals("<A>", sink.result());
 
  }
View Full Code Here

   
    /**
     * Make sure parameterized type names with multiple type parameters are handled properly
     */
    public void testMultiParameterizedTypeName() {
        final StringSink sink = new StringSink("test");
        try {
            emitter.emitParameterizedTypeName(sink, list("A", "B", "C"));
        } finally {
            sink.close();           
        }
        assertEquals("<A, B, C>", sink.result());
 
  }
View Full Code Here

     * If a factory has no args and no type parameters it should be a simple constant
     */
    @Test
    public void testNoArgNoTypesFactory() {
        final Constructor constructor = new Constructor(NO_COMMENTS, "Whatever", Util.<Arg>list());
        final StringSink sink = new StringSink("test");
        try {
            emitter.constructorFactory(sink, "SomeDataType", "SomeFactory", Util.<String>list(), constructor);
        } finally {
            sink.close();           
        }
        assertEquals(NO_ARG_NO_TYPES_FACTORY, sink.result());
    }
View Full Code Here

     * If a factory has no args but does have type parameters it should be a constant with some warning suppression
     */
    @Test
    public void testNoArgTypesFactory() {
        final Constructor constructor = new Constructor(NO_COMMENTS, "Whatever", Util.<Arg>list());
        final StringSink sink = new StringSink("test");
        try {
            emitter.constructorFactory(sink, "SomeDataType", "SomeFactory", list("A", "B"), constructor);
        } finally {
            sink.close();           
        }
        assertEquals(NO_ARG_TYPES_FACTORY, sink.result());
    }
View Full Code Here

        final Constructor constructor = new Constructor(NO_COMMENTS, "Foo", list(
                                new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("Integer", Util.<RefType>list())), "yeah"),
                                new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("String", Util.<RefType>list())), "hmmm")
                        ));
       
        final StringSink sink = new StringSink("test");
        try {
           
            emitter.constructorFactory(sink, "SomeDataType", "SomeFactory", Util.<String>list(), constructor);
        } finally {
            sink.close();           
        }
        assertEquals(ARGS_NO_TYPES_FACTORY, sink.result());
    }
View Full Code Here

        final Constructor constructor = new Constructor(NO_COMMENTS, "Foo", list(
                                new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("Integer", Util.<RefType>list())), "yeah"),
                                new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("String", Util.<RefType>list())), "hmmm")
                        ));
       
        final StringSink sink = new StringSink("test");
        try {
           
            emitter.constructorFactory(sink, "SomeDataType", "SomeFactory", list("A", "B"), constructor);
        } finally {
            sink.close();           
        }
        assertEquals(ARGS_TYPES_FACTORY, sink.result());
    }   
View Full Code Here

    public void testConstructorMethod() {
        final Constructor constructor = new Constructor(list(_JavaDocComment("/**", list(_JDEOL("\n")), list(_JDTagSection("@param", list(_JDWhiteSpace(" "), _JDAsterisk(), _JDWhiteSpace(" "), _JDTag("@param"), _JDWhiteSpace(" "), _JDWord("um"), _JDWhiteSpace(" "), _JDWord("this is the um"), _JDEOL("\n"), _JDWhiteSpace(" ")))), "*/")), "Foo",
                list(new Arg(Util.<ArgModifier>list(), _Ref(_ClassType("String", Util.<RefType> list())), "um"), new Arg(Util.list(_Final(), _Transient(), _Volatile()), _Primitive(_IntType()),
                        "yeah")));

        final StringSink sink = new StringSink("test");
        try {
            emitter.emitConstructorMethod(sink, "    ", constructor);
        } finally {
            sink.close();
        }
        assertEquals(CONSTRUCTOR_METHOD, sink.result());
    }
View Full Code Here

TOP

Related Classes of com.pogofish.jadt.sink.StringSink

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.