@Test public void shouldSubscribeToFeatureSet() { allSubscriptions = allSubscriptions.subList(2, 4); boolean actual1 = Store.isSubscribedToFeatureSet(allSubscriptions, "project1", "fs_1"); boolean expected1 = false; boolean actual2 = Store.isSubscribedToFeatureSet(allSubscriptions, "project1", "fs_2"); boolean expected2 = true; boolean actual3 = Store.isSubscribedToFeatureSet(allSubscriptions, "project1", "fs_nonexistent"); boolean expected3 = false; assertThat(actual1, equalTo(expected1)); assertThat(actual2, equalTo(expected2)); assertThat(actual3, equalTo(expected3)); }
public static boolean isSubscribedToFeatureSet( List<Subscription> subscriptions, String projectName, String featureSetName) { for (Subscription sub : subscriptions) { if (sub.getProject().isEmpty() || sub.getName().isEmpty()) { throw new IllegalArgumentException( String.format("Subscription is missing arguments: %s", sub.toString())); } Pattern patternName = getNamePattern(sub); Pattern patternProject = getProjectPattern(sub); if (patternProject.matcher(projectName).matches() && patternName.matcher(featureSetName).matches() && sub.getExclude()) { return false; } } List<Subscription> filteredSubscriptions = subscriptions.stream().filter(sub -> !sub.getExclude()).collect(Collectors.toList()); for (Subscription filteredSub : filteredSubscriptions) { Pattern patternName = getNamePattern(filteredSub); Pattern patternProject = getProjectPattern(filteredSub); if (patternProject.matcher(projectName).matches() && patternName.matcher(featureSetName).matches()) { return true; } } return false; }
Store { public static boolean isSubscribedToFeatureSet( List<Subscription> subscriptions, String projectName, String featureSetName) { for (Subscription sub : subscriptions) { if (sub.getProject().isEmpty() || sub.getName().isEmpty()) { throw new IllegalArgumentException( String.format("Subscription is missing arguments: %s", sub.toString())); } Pattern patternName = getNamePattern(sub); Pattern patternProject = getProjectPattern(sub); if (patternProject.matcher(projectName).matches() && patternName.matcher(featureSetName).matches() && sub.getExclude()) { return false; } } List<Subscription> filteredSubscriptions = subscriptions.stream().filter(sub -> !sub.getExclude()).collect(Collectors.toList()); for (Subscription filteredSub : filteredSubscriptions) { Pattern patternName = getNamePattern(filteredSub); Pattern patternProject = getProjectPattern(filteredSub); if (patternProject.matcher(projectName).matches() && patternName.matcher(featureSetName).matches()) { return true; } } return false; } }
Store { public static boolean isSubscribedToFeatureSet( List<Subscription> subscriptions, String projectName, String featureSetName) { for (Subscription sub : subscriptions) { if (sub.getProject().isEmpty() || sub.getName().isEmpty()) { throw new IllegalArgumentException( String.format("Subscription is missing arguments: %s", sub.toString())); } Pattern patternName = getNamePattern(sub); Pattern patternProject = getProjectPattern(sub); if (patternProject.matcher(projectName).matches() && patternName.matcher(featureSetName).matches() && sub.getExclude()) { return false; } } List<Subscription> filteredSubscriptions = subscriptions.stream().filter(sub -> !sub.getExclude()).collect(Collectors.toList()); for (Subscription filteredSub : filteredSubscriptions) { Pattern patternName = getNamePattern(filteredSub); Pattern patternProject = getProjectPattern(filteredSub); if (patternProject.matcher(projectName).matches() && patternName.matcher(featureSetName).matches()) { return true; } } return false; }  }
Store { public static boolean isSubscribedToFeatureSet( List<Subscription> subscriptions, String projectName, String featureSetName) { for (Subscription sub : subscriptions) { if (sub.getProject().isEmpty() || sub.getName().isEmpty()) { throw new IllegalArgumentException( String.format("Subscription is missing arguments: %s", sub.toString())); } Pattern patternName = getNamePattern(sub); Pattern patternProject = getProjectPattern(sub); if (patternProject.matcher(projectName).matches() && patternName.matcher(featureSetName).matches() && sub.getExclude()) { return false; } } List<Subscription> filteredSubscriptions = subscriptions.stream().filter(sub -> !sub.getExclude()).collect(Collectors.toList()); for (Subscription filteredSub : filteredSubscriptions) { Pattern patternName = getNamePattern(filteredSub); Pattern patternProject = getProjectPattern(filteredSub); if (patternProject.matcher(projectName).matches() && patternName.matcher(featureSetName).matches()) { return true; } } return false; }  static List<Subscription> parseSubFromStr(String subscriptions); static List<Subscription> parseSubFromStrWithoutExclusions(String subscriptions); static String parseSubscriptionFrom(Subscription subscription); static Subscription convertStringToSubscription(String subscription); static boolean isSubscribedToFeatureSet(
      List<Subscription> subscriptions, String projectName, String featureSetName); }
Store { public static boolean isSubscribedToFeatureSet( List<Subscription> subscriptions, String projectName, String featureSetName) { for (Subscription sub : subscriptions) { if (sub.getProject().isEmpty() || sub.getName().isEmpty()) { throw new IllegalArgumentException( String.format("Subscription is missing arguments: %s", sub.toString())); } Pattern patternName = getNamePattern(sub); Pattern patternProject = getProjectPattern(sub); if (patternProject.matcher(projectName).matches() && patternName.matcher(featureSetName).matches() && sub.getExclude()) { return false; } } List<Subscription> filteredSubscriptions = subscriptions.stream().filter(sub -> !sub.getExclude()).collect(Collectors.toList()); for (Subscription filteredSub : filteredSubscriptions) { Pattern patternName = getNamePattern(filteredSub); Pattern patternProject = getProjectPattern(filteredSub); if (patternProject.matcher(projectName).matches() && patternName.matcher(featureSetName).matches()) { return true; } } return false; }  static List<Subscription> parseSubFromStr(String subscriptions); static List<Subscription> parseSubFromStrWithoutExclusions(String subscriptions); static String parseSubscriptionFrom(Subscription subscription); static Subscription convertStringToSubscription(String subscription); static boolean isSubscribedToFeatureSet(
      List<Subscription> subscriptions, String projectName, String featureSetName);  }