@Test public void buildListFilterTest() throws Exception { MongoConnectionHandler connectionHandler = Mockito.mock(MongoConnectionHandler.class); Connection<MongoClient> connection = Mockito.mock(Connection.class); MongoClient client = Mockito.mock(MongoClient.class); DB database = Mockito.mock(DB.class); DBCollection collection = Mockito.mock(DBCollection.class); MongoStorageEngine mongoStorageEngine; when(connectionHandler.getConnection(CLUSTER_NAME)).thenReturn(connection); when(connection.getNativeConnection()).thenReturn(client); mongoStorageEngine = MongoStorageEngine.getInstance((MongoConnectionHandler) connectionHandler); when(client.getDB(DB_NAME)).thenReturn(database); when(client.getDB(DB_NAME)).thenReturn(database); when(database.getCollection(COLLECTION_NAME)).thenReturn(collection); Set<Operations> operations = new HashSet<>(); operations.add(Operations.FILTER_INDEXED_GT); Collection<Filter> whereClauses = Arrays.asList(new Filter(operations, getBasicRelation( COLUMN_NAME, Operator.GET, 20))); Method method = mongoStorageEngine.getClass().getDeclaredMethod("buildFilter", Collection.class); method.setAccessible(true); FilterDBObjectBuilder filterBuilder = mock(FilterDBObjectBuilder.class); PowerMockito.whenNew(FilterDBObjectBuilder.class).withArguments(false, whereClauses).thenReturn(filterBuilder); DBObject filter = (DBObject) method.invoke(mongoStorageEngine, (Collection<Filter>) null); Assert.assertEquals("The built filter is not the expected", new BasicDBObject(), filter); }
public static MongoStorageEngine getInstance(MongoConnectionHandler connectionHandler){ if(instance == null){ instance = new MongoStorageEngine(connectionHandler); } return instance; }
MongoStorageEngine extends CommonsStorageEngine<MongoClient> { public static MongoStorageEngine getInstance(MongoConnectionHandler connectionHandler){ if(instance == null){ instance = new MongoStorageEngine(connectionHandler); } return instance; } }
MongoStorageEngine extends CommonsStorageEngine<MongoClient> { public static MongoStorageEngine getInstance(MongoConnectionHandler connectionHandler){ if(instance == null){ instance = new MongoStorageEngine(connectionHandler); } return instance; } private  MongoStorageEngine(MongoConnectionHandler connectionHandler); }
MongoStorageEngine extends CommonsStorageEngine<MongoClient> { public static MongoStorageEngine getInstance(MongoConnectionHandler connectionHandler){ if(instance == null){ instance = new MongoStorageEngine(connectionHandler); } return instance; } private  MongoStorageEngine(MongoConnectionHandler connectionHandler); static MongoStorageEngine getInstance(MongoConnectionHandler connectionHandler); }
MongoStorageEngine extends CommonsStorageEngine<MongoClient> { public static MongoStorageEngine getInstance(MongoConnectionHandler connectionHandler){ if(instance == null){ instance = new MongoStorageEngine(connectionHandler); } return instance; } private  MongoStorageEngine(MongoConnectionHandler connectionHandler); static MongoStorageEngine getInstance(MongoConnectionHandler connectionHandler);  }