* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.att.research.xacml.api.Obligation;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import java.util.Collections;
import java.util.Map;
import lombok.AccessLevel;
import lombok.Getter;
@SuppressWarnings("unchecked")
public Map<String, Object> getPolicyContentAsMap() {
if (this.policyContent == null) {
- return null;
+ return Collections.emptyMap();
}
return gson.fromJson(this.policyContent, Map.class);
}
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// Sanity check that we got the attributes we care about. NOTE: This translator
// ensures that these are set when convertPolicy is called.
//
- if (! Strings.isNullOrEmpty(policyId) && policyContent != null) {
+ if (! Strings.isNullOrEmpty(policyId) && !policyContent.isEmpty()) {
decisionResponse.getPolicies().put(policyId, policyContent);
} else {
LOGGER.error("Missing obligation policyId {} or policyContent {}", policyId,
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
assertNull(translator.convertRequest(null));
assertThat(translator.generateAnyOfForPolicyType("foo.bar")).isNotNull();
- assertThat(translator.generateAnyOfForPolicyType("foo.bar").getAllOf().size()).isEqualTo(1);
+ assertThat(translator.generateAnyOfForPolicyType("foo.bar").getAllOf()).hasSize(1);
assertThat(translator.generateConditionForPolicyType("foo.bar")).isNotNull();
assertThat(translator.generateConditionForPolicyType("foo.bar").getExpression()).isNotNull();
translator.addObligation(policySet, "policy.id", policyJson, 0, "foo.bar");
- assertThat(policySet.getObligationExpressions().getObligationExpression().size()).isEqualTo(1);
+ assertThat(policySet.getObligationExpressions().getObligationExpression()).hasSize(1);
assertThat(policySet.getObligationExpressions().getObligationExpression().get(0)
- .getAttributeAssignmentExpression().size()).isEqualTo(4);
+ .getAttributeAssignmentExpression()).hasSize(4);
PolicyType policy = new PolicyType();
translator.addObligation(policy, null, policyJson, null, null);
- assertThat(policy.getObligationExpressions().getObligationExpression().size()).isEqualTo(1);
+ assertThat(policy.getObligationExpressions().getObligationExpression()).hasSize(1);
assertThat(policy.getObligationExpressions().getObligationExpression().get(0)
- .getAttributeAssignmentExpression().size()).isEqualTo(1);
+ .getAttributeAssignmentExpression()).hasSize(1);
RuleType rule = new RuleType();
translator.addObligation(rule, "policy.id", null, null, "foo.bar");
- assertThat(rule.getObligationExpressions().getObligationExpression().size()).isEqualTo(1);
+ assertThat(rule.getObligationExpressions().getObligationExpression()).hasSize(1);
assertThat(rule.getObligationExpressions().getObligationExpression().get(0)
- .getAttributeAssignmentExpression().size()).isEqualTo(2);
+ .getAttributeAssignmentExpression()).hasSize(2);
rule = new RuleType();
translator.addObligation(rule, null, null, null, null);
- assertThat(rule.getObligationExpressions().getObligationExpression().size()).isEqualTo(1);
+ assertThat(rule.getObligationExpressions().getObligationExpression()).hasSize(1);
assertThat(rule.getObligationExpressions().getObligationExpression().get(0)
.getAttributeAssignmentExpression()).isEmpty();
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
//
// Decisions
//
- assertThat(service.actionDecisionsSupported().size()).isEqualTo(1);
+ assertThat(service.actionDecisionsSupported()).hasSize(1);
assertThat(service.actionDecisionsSupported()).contains("guard");
//
// Ensure it has the supported policy types and
// can support the correct policy types.
//
assertThat(service.supportedPolicyTypes()).isNotEmpty();
- assertThat(service.supportedPolicyTypes().size()).isEqualTo(5);
+ assertThat(service.supportedPolicyTypes()).hasSize(5);
assertThat(service.canSupportPolicyType(
new ToscaConceptIdentifier("onap.policies.controlloop.guard.common.FrequencyLimiter", "1.0.0")))
.isTrue();
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
//
// Decisions
//
- assertThat(service.actionDecisionsSupported().size()).isEqualTo(1);
+ assertThat(service.actionDecisionsSupported()).hasSize(1);
assertThat(service.actionDecisionsSupported()).contains("match");
//
// Ensure it has the supported policy types and
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
//
// Decisions
//
- assertThat(service.actionDecisionsSupported().size()).isEqualTo(1);
+ assertThat(service.actionDecisionsSupported()).hasSize(1);
assertThat(service.actionDecisionsSupported()).contains("naming");
//
// Ensure it has the supported policy types and
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
//
// Does it return the correct decisions
//
- assertThat(service.actionDecisionsSupported().size()).isEqualTo(1);
+ assertThat(service.actionDecisionsSupported()).hasSize(1);
assertThat(service.actionDecisionsSupported()).contains("optimize");
//
// Ensure it has the supported policy types and
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2022 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// We need at least 1 policies
//
assertThat(completedJtst).isNotNull();
- assertThat(completedJtst.getToscaTopologyTemplate().getPolicies().size()).isPositive();
+ assertThat(completedJtst.getToscaTopologyTemplate().getPolicies()).isNotEmpty();
//
// Copy test directory over of the application directories
//