mil.dod.th.ose.jaxb.proto.converter/test/mil/dod/th/ose/jaxbprotoconverter/TestEnumConverterFileGenerator.java
@Test
    public void testGenEnumConverterFile() throws IOException
    {
        //construct enum
        ProtoEnum protoEnum = new ProtoEnum(null, null, null, null, null);
        protoEnum.setType(TestEnum.class);
        protoEnum.setName("Enum");
        String enum1 = "One";
        String enum2 = "Two";
        List<String> enumVals = new ArrayList<String>();
        enumVals.add(enum1);
        enumVals.add(enum2);
        
        //add the enum values
        protoEnum.setValues(enumVals);
        
        ByteArrayOutputStream baot = new ByteArrayOutputStream();
        m_PrintStream = new PrintStream(baot);
        String protoClassName = "ProtoClassName";
        String packageName = "test.package";
        
        m_SUT.genEnumConverterFile(protoEnum, m_PrintStream, protoClassName, "test.proto", packageName);
        
        String expectFileContent = new String(Files.readAllBytes(
                new File("resources/TestProtoConverter.java").toPath()));
        
        //normalize line endings for easy comparison
        String output = normalizeLineEndings(baot.toString());
        
        //verify timestamp generation
        output = assertTimeStampGeneration(output);
        
        //remove header from file input
        expectFileContent = removeFileHeader(expectFileContent);
        //normalize file input
        expectFileContent = normalizeLineEndings(expectFileContent);

        //trim off ending/starting new lines
        assertThat(output.trim(), is(expectFileContent.trim()));
        
        //create clean stream and printstream
        baot = new ByteArrayOutputStream();
        m_PrintStream = new PrintStream(baot);
        
        m_SUT.genEnumConverterWrapperFile(m_PrintStream, "TestEnum", "test.package");

        expectFileContent = new String(Files.readAllBytes(
                new File("resources/TestProtoConverterGenerator.java").toPath()));

        //normalize line endings for easy comparison
        output = normalizeLineEndings(baot.toString());
        
        //verify timestamp generation
        output = assertTimeStampGeneration(output);
        
        //remove header from file input
        expectFileContent = removeFileHeader(expectFileContent);
        //normalize file input
        expectFileContent = normalizeLineEndings(expectFileContent);
        
        //trim off ending/starting new lines
        assertThat(output.trim(), is(expectFileContent.trim())); 
    }
/**
     * Verify creation of enum converter file based of a proto enum.
     */
Verify creation of enum converter file based of a proto enum.
Verify creation of enum converter file based of a proto enum .
@Test
    public void testGenEnumConverterFile() throws IOException
    {
        ProtoEnum protoEnum = new ProtoEnum(null, null, null, null, null);
        protoEnum.setType(TestEnum.class);
        protoEnum.setName("Enum");
        String enum1 = "One";
        String enum2 = "Two";
        List<String> enumVals = new ArrayList<String>();
        enumVals.add(enum1);
        enumVals.add(enum2);
        protoEnum.setValues(enumVals);
        ByteArrayOutputStream baot = new ByteArrayOutputStream();
        m_PrintStream = new PrintStream(baot);
        String protoClassName = "ProtoClassName";
        String packageName = "test.package";
        m_SUT.genEnumConverterFile(protoEnum, m_PrintStream, protoClassName, "test.proto", packageName);
        String expectFileContent = new String(Files.readAllBytes(
                new File("resources/TestProtoConverter.java").toPath()));
        String output = normalizeLineEndings(baot.toString());
        output = assertTimeStampGeneration(output);
        expectFileContent = removeFileHeader(expectFileContent);
        expectFileContent = normalizeLineEndings(expectFileContent);
        assertThat(output.trim(), is(expectFileContent.trim()));
        baot = new ByteArrayOutputStream();
        m_PrintStream = new PrintStream(baot);
        m_SUT.genEnumConverterWrapperFile(m_PrintStream, "TestEnum", "test.package");
        expectFileContent = new String(Files.readAllBytes(
                new File("resources/TestProtoConverterGenerator.java").toPath()));
        output = normalizeLineEndings(baot.toString());
        output = assertTimeStampGeneration(output);
        expectFileContent = removeFileHeader(expectFileContent);
        expectFileContent = normalizeLineEndings(expectFileContent);
        assertThat(output.trim(), is(expectFileContent.trim())); 
    }
@ Test public void testGenEnumConverterFile ( ) throws IOException { ProtoEnum protoEnum = new ProtoEnum ( null , null , null , null , null ) ; protoEnum . setType ( TestEnum . class ) ; protoEnum . setName ( "Enum" ) ; String enum1 = "One" ; String enum2 = "Two" ; List < String > enumVals = new ArrayList < String > ( ) ; enumVals . add ( enum1 ) ; enumVals . add ( enum2 ) ; protoEnum . setValues ( enumVals ) ; ByteArrayOutputStream baot = new ByteArrayOutputStream ( ) ; m_PrintStream = new PrintStream ( baot ) ; String protoClassName = "ProtoClassName" ; String packageName = "test.package" ; m_SUT . genEnumConverterFile ( protoEnum , m_PrintStream , protoClassName , "test.proto" , packageName ) ; String expectFileContent = new String ( Files . readAllBytes ( new File ( "resources/TestProtoConverter.java" ) . toPath ( ) ) ) ; String output = normalizeLineEndings ( baot . toString ( ) ) ; output = assertTimeStampGeneration ( output ) ; expectFileContent = removeFileHeader ( expectFileContent ) ; expectFileContent = normalizeLineEndings ( expectFileContent ) ; assertThat ( output . trim ( ) , is ( expectFileContent . trim ( ) ) ) ; baot = new ByteArrayOutputStream ( ) ; m_PrintStream = new PrintStream ( baot ) ; m_SUT . genEnumConverterWrapperFile ( m_PrintStream , "TestEnum" , "test.package" ) ; expectFileContent = new String ( Files . readAllBytes ( new File ( "resources/TestProtoConverterGenerator.java" ) . toPath ( ) ) ) ; output = normalizeLineEndings ( baot . toString ( ) ) ; output = assertTimeStampGeneration ( output ) ; expectFileContent = removeFileHeader ( expectFileContent ) ; expectFileContent = normalizeLineEndings ( expectFileContent ) ; assertThat ( output . trim ( ) , is ( expectFileContent . trim ( ) ) ) ; }
Verify creation of enum converter file based of a proto enum.
Verify creation of enum converter file based of a proto enum .
//construct enum //add the enum values //normalize line endings for easy comparison //verify timestamp generation //remove header from file input //normalize file input //trim off ending/starting new lines //create clean stream and printstream //normalize line endings for easy comparison //verify timestamp generation //remove header from file input //normalize file input //trim off ending/starting new lines