Package org.apache.onami.test.annotation

Examples of org.apache.onami.test.annotation.Mock


            checkState( !isTypeConflicts, "   Found multiple annotation @%s for type: %s; binding skipped!.",
                        Mock.class.getSimpleName(), type );
            for ( final Field field : fields )
            {
                final TypeLiteral literal = TypeLiteral.get( type );
                final Mock annoBy = field.getAnnotation( Mock.class );
                final Object mock = this.mockedFields.get( field );
                if ( annoBy.annotatedWith() != Mock.NoAnnotation.class )
                {
                    bind( literal ).annotatedWith( annoBy.annotatedWith() ).toInstance( mock );
                }
                else if ( !"".equals( annoBy.namedWith() ) )
                {
                    bind( literal ).annotatedWith( Names.named( annoBy.namedWith() ) ).toInstance( mock );
                }
                else
                {
                    bind( literal ).toInstance( mock );
                }
View Full Code Here


        final List<String> listNamedType = new ArrayList<String>();
        int numOfSimpleType = 0;

        for ( Field field : fields )
        {
            final Mock annoBy = field.getAnnotation( Mock.class );

            if ( annoBy.annotatedWith() == Mock.NoAnnotation.class && "".equals( annoBy.namedWith() ) )
            {
                numOfSimpleType++;
            }
            if ( numOfSimpleType > 1 )
            {
                LOGGER.finer( "Found multiple simple type" );
                return true;
            }

            if ( annoBy.annotatedWith() != Mock.NoAnnotation.class )
            {
                if ( !listAnnotatedType.contains( annoBy.annotatedWith() ) )
                {
                    listAnnotatedType.add( annoBy.annotatedWith() );
                }
                else
                {
                    // found two fields with same annotation
                    LOGGER.finer( "Found multiple annotatedBy type" );
                    return true;
                }
            }

            if ( !"".equals( annoBy.namedWith() ) )
            {
                if ( !listNamedType.contains( annoBy.namedWith() ) )
                {
                    listNamedType.add( annoBy.namedWith() );
                }
                else
                {
                    // found two fields with same named annotation
                    LOGGER.finer( "Found multiple namedWith type" );
View Full Code Here

    private void resetAllResetAfterMocks()
    {
        for ( Entry<Field, Object> entry : mocked.entrySet() )
        {
            final Mock mockAnnotation = entry.getKey().getAnnotation( Mock.class );
            if ( mockAnnotation.resetAfter() )
            {
                MockEngine mockEngine = MockEngineFactory.getMockEngine( mockFramework );
                mockEngine.resetMock( entry.getValue() );
            }
        }
View Full Code Here

        for ( Entry<Field, Object> entry : mockedObjects.entrySet() )
        {
            if ( entry.getValue() instanceof Class<?> )
            {
                Field field = entry.getKey();
                Mock mock = field.getAnnotation( Mock.class );
                mockedObjects.put( entry.getKey(), engine.createMock( (Class<?>) entry.getValue(), mock.type() ) );
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.onami.test.annotation.Mock

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.