public Collection<ExternalResourceDescriptor> locateExternalResourceName( Trace trace, Collection<Frame> dbFrames) { if (ListUtil.size(dbFrames) <= 0) { return Collections.emptyList(); } List<ExternalResourceDescriptor> dbDescriptors = new ArrayList<ExternalResourceDescriptor>(dbFrames.size()); for (Frame dbFrame : dbFrames) { Operation op = dbFrame.getOperation(); String host = op.get("host", String.class); int port = op.getInt("port", (-1)); String dbName = op.get("dbName", String.class); String mongoHash = MD5NameGenerator.getName(dbName + host + port); String color = colorManager.getColor(op); dbDescriptors.add( new ExternalResourceDescriptor( dbFrame, "mongo:" + mongoHash, dbName, ExternalResourceType.DATABASE.name(), MONGODB_VENDOR, host, port, color, false)); } return dbDescriptors; }
@Test public void testSetWithDbName() { DummyJedisCommands client = new DummyJedisCommands("localhost"); client.set("mykey", "myvalue"); Operation op = getLastEntered(); assertNotNull("No operation extracted", op); assertEquals("Mismatched method name", "set", op.get("methodName")); assertEquals("Mismatched label", "Redis: mykey.set", op.getLabel()); assertEquals( "Mismatched argument value", "mykey", op.get(OperationFields.ARGUMENTS, OperationList.class).get(0)); assertEquals("Mismatched host", "localhost", op.get("host")); assertEquals("Mismatched port", 6379, op.getInt("port", (-1))); assertEquals("Mismatched DB name", "0", op.get("dbName")); }