/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020 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 java.util.Map;
import org.junit.Test;
import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.base.PfValidationResult;
+import org.onap.policy.models.base.Validated;
import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityAssignment;
/**
assertEquals(caKey, ca.getKeys().get(0));
ca.clean();
- ca.validate(new PfValidationResult());
+ ca.validate("");
assertThat(ca.getProperties()).isNullOrEmpty();
assertThat(ca.getAttributes()).isNullOrEmpty();
ca.setAttributes(null);
ca.setOccurrences(null);
ca.clean();
- ca.validate(new PfValidationResult());
+ ca.validate("");
assertEquals(null, ca.getProperties());
assertEquals(null, ca.getAttributes());
ca.setOccurrences(occurrences);
ca.clean();
- ca.validate(new PfValidationResult());
+ ca.validate("");
assertEquals("Untrimmed Value", ca.getProperties().get("Key0"));
assertEquals("Untrimmed Value", ca.getAttributes().get("Key0"));
ca.getAttributes().put("Key1", null);
ca.getOccurrences().add(null);
ca.getOccurrences().add(-12345);
- PfValidationResult result = ca.validate(new PfValidationResult());
- assertThat(result.toString()).contains("capability assignment property Key1 value may not be null");
- assertThat(result.toString()).contains("capability assignment attribute Key1 value may not be null");
- assertThat(result.toString()).contains("capability assignment occurrence value may not be negative");
+ assertThat(ca.validate("").getResult())
+ .contains("properties").contains("Key1").contains(Validated.IS_NULL)
+ .contains("attributes").contains("Key1").contains(Validated.IS_NULL)
+ .contains("occurrence").contains("value").contains("is below the minimum value: 0");
}
@Test