mil.dod.th.ose.test/src/mil/dod/th/ose/test/BundleContextMocker.java
public static Filter stubFilter(BundleContext context)
    {
        final Filter filter = mock(Filter.class);
        
        try
        {
            when(context.createFilter(anyString())).thenAnswer(new Answer<Filter>()
            {
                @Override
                public Filter answer(InvocationOnMock invocation) throws Throwable
                {
                    String filterStr = (String)invocation.getArguments()[0];
                    
                    when(filter.toString()).thenReturn(filterStr);
                    
                    return filter;
                }               
            });
        }
        catch (InvalidSyntaxException e)
        {
            throw new IllegalStateException(e);
        }
        
        return filter;
    }
/**
     * Stub context to return the given filter.
     */
Stub context to return the given filter.
Stub context to return the given filter .
public static Filter stubFilter(BundleContext context)
    {
        final Filter filter = mock(Filter.class);
        try
        {
            when(context.createFilter(anyString())).thenAnswer(new Answer<Filter>()
            {
                @Override
                public Filter answer(InvocationOnMock invocation) throws Throwable
                {
                    String filterStr = (String)invocation.getArguments()[0];
                    when(filter.toString()).thenReturn(filterStr);
                    return filter;
                }               
            });
        }
        catch (InvalidSyntaxException e)
        {
            throw new IllegalStateException(e);
        }
        return filter;
    }
public static Filter stubFilter ( BundleContext context ) { final Filter filter = mock ( Filter . class ) ; try { when ( context . createFilter ( anyString ( ) ) ) . thenAnswer ( new Answer < Filter > ( ) { @ Override public Filter answer ( InvocationOnMock invocation ) throws Throwable { String filterStr = ( String ) invocation . getArguments ( ) [ 0 ] ; when ( filter . toString ( ) ) . thenReturn ( filterStr ) ; return filter ; } } ) ; } catch ( InvalidSyntaxException e ) { throw new IllegalStateException ( e ) ; } return filter ; }
Stub context to return the given filter.
Stub context to return the given filter .