* @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