@Test public void testAssembleRuleGroups() throws Exception { final UnconfiguredResolvedRuleBuilder unconfiguredResolvedRuleBuilder = new UnconfiguredResolvedRuleBuilder(); unconfiguredResolvedRuleBuilder.setRuleName(new RuleName("rule-name")); final UnconfiguredResolvedRule resolvedRule = unconfiguredResolvedRuleBuilder.build(); final PolicyConfigurationContext context = new PolicyConfigurationContext(); context.setCurrentUnconfiguredRule(resolvedRule); final RuleGroupWithRendererEndpointParticipation ruleGroup = new RuleGroupWithRendererEndpointParticipationBuilder() .setTenantId(TENANT_ID) .setSubjectName(SUBJECT_NAME) .setContractId(CONTRACT_ID) .setRendererEndpointParticipation(EndpointPolicyParticipation.CONSUMER) .build(); final List<UnconfiguredRuleGroup> gatheredRuleGroups = StatusUtil.assembleRuleGroups(Stream.of(ruleGroup), context); Assert.assertEquals(1, gatheredRuleGroups.size()); final UnconfiguredRuleGroup actual = gatheredRuleGroups.get(0); Assert.assertEquals(TENANT_ID, actual.getTenantId()); Assert.assertEquals(SUBJECT_NAME, actual.getSubjectName()); Assert.assertEquals(CONTRACT_ID, actual.getContractId()); Assert.assertEquals(Collections.singletonList(resolvedRule), actual.getUnconfiguredResolvedRule()); Assert.assertEquals(EndpointPolicyParticipation.CONSUMER, actual.getRendererEndpointParticipation()); }
@VisibleForTesting static List<UnconfiguredRuleGroup> assembleRuleGroups(final Stream<RuleGroupWithRendererEndpointParticipation> stream, final PolicyConfigurationContext context) { return stream .filter(Objects::nonNull) .map((ruleGroup) -> new UnconfiguredRuleGroupBuilder(ruleGroup) .setRendererEndpointParticipation(ruleGroup.getRendererEndpointParticipation()) .setUnconfiguredResolvedRule(assembleResolvedRule(Stream.of(context.getCurrentUnconfiguredRule()), context)) .build()) .collect(Collectors.toList()); }
StatusUtil { @VisibleForTesting static List<UnconfiguredRuleGroup> assembleRuleGroups(final Stream<RuleGroupWithRendererEndpointParticipation> stream, final PolicyConfigurationContext context) { return stream .filter(Objects::nonNull) .map((ruleGroup) -> new UnconfiguredRuleGroupBuilder(ruleGroup) .setRendererEndpointParticipation(ruleGroup.getRendererEndpointParticipation()) .setUnconfiguredResolvedRule(assembleResolvedRule(Stream.of(context.getCurrentUnconfiguredRule()), context)) .build()) .collect(Collectors.toList()); } }
StatusUtil { @VisibleForTesting static List<UnconfiguredRuleGroup> assembleRuleGroups(final Stream<RuleGroupWithRendererEndpointParticipation> stream, final PolicyConfigurationContext context) { return stream .filter(Objects::nonNull) .map((ruleGroup) -> new UnconfiguredRuleGroupBuilder(ruleGroup) .setRendererEndpointParticipation(ruleGroup.getRendererEndpointParticipation()) .setUnconfiguredResolvedRule(assembleResolvedRule(Stream.of(context.getCurrentUnconfiguredRule()), context)) .build()) .collect(Collectors.toList()); } private  StatusUtil(); }
StatusUtil { @VisibleForTesting static List<UnconfiguredRuleGroup> assembleRuleGroups(final Stream<RuleGroupWithRendererEndpointParticipation> stream, final PolicyConfigurationContext context) { return stream .filter(Objects::nonNull) .map((ruleGroup) -> new UnconfiguredRuleGroupBuilder(ruleGroup) .setRendererEndpointParticipation(ruleGroup.getRendererEndpointParticipation()) .setUnconfiguredResolvedRule(assembleResolvedRule(Stream.of(context.getCurrentUnconfiguredRule()), context)) .build()) .collect(Collectors.toList()); } private  StatusUtil(); static UnconfiguredRendererEndpoint assembleFullyNotConfigurableRendererEP(final PolicyConfigurationContext context,
                                                                                      final String info); static UnconfiguredRendererEndpoint assembleNotConfigurableRendererEPForPeer(final PolicyConfigurationContext context,
                                                                                        final PeerEndpoint peerEndpoint,
                                                                                        final String info); }
StatusUtil { @VisibleForTesting static List<UnconfiguredRuleGroup> assembleRuleGroups(final Stream<RuleGroupWithRendererEndpointParticipation> stream, final PolicyConfigurationContext context) { return stream .filter(Objects::nonNull) .map((ruleGroup) -> new UnconfiguredRuleGroupBuilder(ruleGroup) .setRendererEndpointParticipation(ruleGroup.getRendererEndpointParticipation()) .setUnconfiguredResolvedRule(assembleResolvedRule(Stream.of(context.getCurrentUnconfiguredRule()), context)) .build()) .collect(Collectors.toList()); } private  StatusUtil(); static UnconfiguredRendererEndpoint assembleFullyNotConfigurableRendererEP(final PolicyConfigurationContext context,
                                                                                      final String info); static UnconfiguredRendererEndpoint assembleNotConfigurableRendererEPForPeer(final PolicyConfigurationContext context,
                                                                                        final PeerEndpoint peerEndpoint,
                                                                                        final String info);  }