Package com.streamreduce.storm

Examples of com.streamreduce.storm.MongoClient


    ConnectionSpout connectionSpout;

    @Before
    public void setUp() throws Exception {
        MongoClient mockMongoClient = mock(MongoClient.class);
        when(mockMongoClient.getConnections()).thenThrow(new RuntimeException("mongo failure"));
        when(mockMongoClient.getConnection(anyString())).thenThrow(new RuntimeException("mongo failure"));

        Logger mockLogger = mock(Logger.class);

        connectionSpout = new ConnectionSpout();
        ReflectionTestUtils.setField(connectionSpout, "mongoClient", mockMongoClient);
View Full Code Here


        Long now = System.currentTimeMillis();
        BasicDBObject earliest = new BasicDBObject("timestamp", now - 10);
        BasicDBObject middle = new BasicDBObject("timestamp", now);
        BasicDBObject latest = new BasicDBObject("timestamp", now + 10);

        MongoClient mockMongoClient = mock(MongoClient.class);
        when(mockMongoClient.getEvents(any(Date.class), any(Date.class))).thenReturn(Lists.newArrayList(latest, earliest, middle));

        Logger mockLogger = mock(Logger.class);

        EventSpout spout = new EventSpout();
        ReflectionTestUtils.setField(spout, "mongoClient", mockMongoClient);
View Full Code Here

    }

    @Test
    public void testGetDBEntriesGracefullyFails() {
        try {
            MongoClient mockMongoClient = mock(MongoClient.class);
            when(mockMongoClient.readLastProcessedEventDate("EventSpout")).thenThrow(new RuntimeException("mongo failure"));

            EventSpout spout = new EventSpout();
            ReflectionTestUtils.setField(spout, "mongoClient", mockMongoClient);
            List<BasicDBObject> entries = spout.getDBEntries();
View Full Code Here

        }
    }

    @Test
    public void testGetDBEntryGracefullyFails() {
        MongoClient mockMongoClient = mock(MongoClient.class);
        when(mockMongoClient.getEvent(anyString())).thenThrow(new RuntimeException("mongo failure"));

        EventSpout spout = new EventSpout();
        ReflectionTestUtils.setField(spout, "mongoClient", mockMongoClient);
        BasicDBObject basicDBObject  = spout.getDBEntry("");
View Full Code Here

     * @throws Exception if anything goes wrong
     */
    @Test
    @Ignore("This test assumes a mongo instance is alive on localhost at 27017.  Ignored until this restriction is lifted")
    public void testExecute() throws Exception {
        MongoClient mongoClient = new MongoClient(MongoClient.BUSINESSDB_CONFIG_ID);
        List<BasicDBObject> connections = mongoClient.getConnections();

        for (BasicDBObject connection : connections) {
            InternalConnectionInventoryBolt bolt = new InternalConnectionInventoryBolt();
            MockOutputCollector outputCollector = new MockOutputCollector();
            Tuple tuple = mock(Tuple.class);
            List<BasicDBObject> expectedInventoryItems = new ArrayList<>();
            String connectionId = connection.getString("_id");
            final String connectionType = connection.getString("type");

            when(tuple.getValue(0)).thenReturn(connection);

            bolt.prepare(null, null, new OutputCollector(outputCollector));

            bolt.execute(tuple);

            if (connectionType.equals(ConnectionTypeConstants.PROJECT_HOSTING_TYPE)) {
                expectedInventoryItems = mongoClient.getProjectHostingInventoryItems(connectionId);
            } else if (connectionType.equals(ConnectionTypeConstants.CLOUD_TYPE)) {
               expectedInventoryItems = mongoClient.getCloudInventoryItems(connectionId);
            }

            List<Values> emittedTuples = outputCollector.getEmittedValues();

            // Make sure all tuples are acked
View Full Code Here

TOP

Related Classes of com.streamreduce.storm.MongoClient

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.