@Test public void testGetCompositeValue() { String snmpResult = "1327451762,42,23,11,0,1|1327451763,11,0,11,0,1|1327451764,11,0,11,0,1|1327451765,11,0,11,0,1|1327451766,11,0,11,0,1|1327451767,11,0,11,0,1|1327451768,11,0,11,0,1|1327451769,11,0,11,0,1|1327451770,11,0,11,0,1|1327451771,11,0,11,0,1|1327451772,11,0,11,0,1|1327451773,11,0,11,0,1|1327451774,11,0,11,0,1|1327451775,11,0,11,0,1|1327451776,11,0,11,0,1|1327451777,11,0,11,0,1|1327451778,11,0,11,0,1|1327451779,11,0,11,0,1|1327451780,11,0,11,0,1|1327451781,11,0,11,0,1|1327451782,11,0,11,0,1|1327451783,11,0,11,0,1|1327451784,11,0,11,0,1|1327451785,11,0,11,0,1|1327451786,12,0,11,0,423|"; TcaProtocolCollector tcaProtocolCollector = (TcaProtocolCollector)protocolCollector; String result = tcaProtocolCollector.getCompositeValue("inboundDelay", "|1|" + snmpResult); Assert.assertEquals("42", result); result = tcaProtocolCollector.getCompositeValue("inboundJitter", "|1|" + snmpResult); Assert.assertEquals("23", result); result = tcaProtocolCollector.getCompositeValue("timesyncStatus", "|25|" + snmpResult ); Assert.assertEquals("423", result); Assert.assertNull(tcaProtocolCollector.getCompositeValue("foo", "|1|" + snmpResult)); Assert.assertNull(tcaProtocolCollector.getCompositeValue(null, "|1|" + snmpResult)); Assert.assertNull(tcaProtocolCollector.getCompositeValue("inboundDelay", null)); }
protected String getCompositeValue(String keyword, String snmpResult) { String result = null; if (snmpResult != null && keyword != null && keywords.contains(keyword)) { String[] snmpResultSets = snmpResult.split("\\|"); Integer amount = Integer.parseInt(snmpResultSets[1]); String snmpResultSubSet = snmpResultSets[amount +1]; String[] results = snmpResultSubSet.split(","); result = results[keywords.indexOf(keyword) +1]; } return result; }
TcaProtocolCollector implements ProtocolCollector { protected String getCompositeValue(String keyword, String snmpResult) { String result = null; if (snmpResult != null && keyword != null && keywords.contains(keyword)) { String[] snmpResultSets = snmpResult.split("\\|"); Integer amount = Integer.parseInt(snmpResultSets[1]); String snmpResultSubSet = snmpResultSets[amount +1]; String[] results = snmpResultSubSet.split(","); result = results[keywords.indexOf(keyword) +1]; } return result; } }
TcaProtocolCollector implements ProtocolCollector { protected String getCompositeValue(String keyword, String snmpResult) { String result = null; if (snmpResult != null && keyword != null && keywords.contains(keyword)) { String[] snmpResultSets = snmpResult.split("\\|"); Integer amount = Integer.parseInt(snmpResultSets[1]); String snmpResultSubSet = snmpResultSets[amount +1]; String[] results = snmpResultSubSet.split(","); result = results[keywords.indexOf(keyword) +1]; } return result; }  }
TcaProtocolCollector implements ProtocolCollector { protected String getCompositeValue(String keyword, String snmpResult) { String result = null; if (snmpResult != null && keyword != null && keywords.contains(keyword)) { String[] snmpResultSets = snmpResult.split("\\|"); Integer amount = Integer.parseInt(snmpResultSets[1]); String snmpResultSubSet = snmpResultSets[amount +1]; String[] results = snmpResultSubSet.split(","); result = results[keywords.indexOf(keyword) +1]; } return result; }  SnmpStrategy getSnmpStrategy(); void setSnmpStrategy(SnmpStrategy snmpStrategy); @Override CollectionJob collect(final CollectionJob collectionJob); @Override String getProtcol(); }
TcaProtocolCollector implements ProtocolCollector { protected String getCompositeValue(String keyword, String snmpResult) { String result = null; if (snmpResult != null && keyword != null && keywords.contains(keyword)) { String[] snmpResultSets = snmpResult.split("\\|"); Integer amount = Integer.parseInt(snmpResultSets[1]); String snmpResultSubSet = snmpResultSets[amount +1]; String[] results = snmpResultSubSet.split(","); result = results[keywords.indexOf(keyword) +1]; } return result; }  SnmpStrategy getSnmpStrategy(); void setSnmpStrategy(SnmpStrategy snmpStrategy); @Override CollectionJob collect(final CollectionJob collectionJob); @Override String getProtcol();  }