@Test public void testGenerate3Pairs() { String tagQuery = "k1=v1,k2=v2,k3=v3"; List<Label> pairs = LabelUtils.generatePairs(tagQuery); assertEquals(3, pairs.size()); assertTrue(pairs.contains(new Label("k1", "v1"))); assertTrue(pairs.contains(new Label("k2", "v2"))); assertTrue(pairs.contains(new Label("k3", "v3"))); }
public static List<Label> generatePairs(String tagQuery) { List<Label> pairList = new ArrayList<>(); if (tagQuery != null) { String[] toks = tagQuery.split(","); if (toks != null && toks.length > 0) { for (int i = 0; i < toks.length; i++) { String token = toks[i]; String[] pairToks = token.split("="); if (pairToks != null && pairToks.length == 2) { pairList.add(new Label(pairToks[0], pairToks[1])); } } } } return pairList; }
LabelUtils { public static List<Label> generatePairs(String tagQuery) { List<Label> pairList = new ArrayList<>(); if (tagQuery != null) { String[] toks = tagQuery.split(","); if (toks != null && toks.length > 0) { for (int i = 0; i < toks.length; i++) { String token = toks[i]; String[] pairToks = token.split("="); if (pairToks != null && pairToks.length == 2) { pairList.add(new Label(pairToks[0], pairToks[1])); } } } } return pairList; } }
LabelUtils { public static List<Label> generatePairs(String tagQuery) { List<Label> pairList = new ArrayList<>(); if (tagQuery != null) { String[] toks = tagQuery.split(","); if (toks != null && toks.length > 0) { for (int i = 0; i < toks.length; i++) { String token = toks[i]; String[] pairToks = token.split("="); if (pairToks != null && pairToks.length == 2) { pairList.add(new Label(pairToks[0], pairToks[1])); } } } } return pairList; }  }
LabelUtils { public static List<Label> generatePairs(String tagQuery) { List<Label> pairList = new ArrayList<>(); if (tagQuery != null) { String[] toks = tagQuery.split(","); if (toks != null && toks.length > 0) { for (int i = 0; i < toks.length; i++) { String token = toks[i]; String[] pairToks = token.split("="); if (pairToks != null && pairToks.length == 2) { pairList.add(new Label(pairToks[0], pairToks[1])); } } } } return pairList; }  static List<Label> generatePairs(String tagQuery); static boolean allPairsPresent(List<Label> expectedTags, List<Label> actualTags); static boolean somePairsPresent(List<Label> expectedTags, List<Label> actualTags); }
LabelUtils { public static List<Label> generatePairs(String tagQuery) { List<Label> pairList = new ArrayList<>(); if (tagQuery != null) { String[] toks = tagQuery.split(","); if (toks != null && toks.length > 0) { for (int i = 0; i < toks.length; i++) { String token = toks[i]; String[] pairToks = token.split("="); if (pairToks != null && pairToks.length == 2) { pairList.add(new Label(pairToks[0], pairToks[1])); } } } } return pairList; }  static List<Label> generatePairs(String tagQuery); static boolean allPairsPresent(List<Label> expectedTags, List<Label> actualTags); static boolean somePairsPresent(List<Label> expectedTags, List<Label> actualTags); static final String OR_OPERAND; static final String AND_OPERAND; static final String LABEL_QUERY_PARAM; static final String LABEL_OP_QUERY_PARAM; }