/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import org.junit.Test;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfReferenceKey;
-import org.onap.policy.models.base.PfValidationResult;
/**
* DAO test for ToscaEventFilter.
assertThatThrownBy(() -> new JpaToscaEventFilter((JpaToscaEventFilter) null))
.isInstanceOf(NullPointerException.class);
+ }
+ @Test
+ public void testEventFilter() {
PfConceptKey efParentKey = new PfConceptKey("tParentKey", VERSION_001);
PfReferenceKey efKey = new PfReferenceKey(efParentKey, "trigger0");
PfConceptKey nodeKey = new PfConceptKey("tParentKey", VERSION_001);
assertEquals(A_CAPABILITY, tef.getCapability());
JpaToscaEventFilter tdtClone0 = new JpaToscaEventFilter(tef);
- assertEquals(tef, tdtClone0);
- assertEquals(0, tef.compareTo(tdtClone0));
+ checkEqualsEventFilter(tef, tdtClone0);
JpaToscaEventFilter tdtClone1 = new JpaToscaEventFilter(tef);
- assertEquals(tef, tdtClone1);
- assertEquals(0, tef.compareTo(tdtClone1));
+ checkEqualsEventFilter(tef, tdtClone1);
assertEquals(-1, tef.compareTo(null));
assertEquals(0, tef.compareTo(tef));
assertEquals(2, tef.getKeys().size());
assertEquals(2, new JpaToscaEventFilter().getKeys().size());
+ }
+
+ private void checkEqualsEventFilter(JpaToscaEventFilter tef1, JpaToscaEventFilter tef2) {
+ assertEquals(tef1, tef2);
+ assertEquals(0, tef1.compareTo(tef2));
+ }
+
+ @Test
+ public void testValidationEventFilter() {
+ PfConceptKey efParentKey = new PfConceptKey("tParentKey", VERSION_001);
+ PfReferenceKey efKey = new PfReferenceKey(efParentKey, "trigger0");
+ PfConceptKey nodeKey = new PfConceptKey("tParentKey", VERSION_001);
+ JpaToscaEventFilter tef = new JpaToscaEventFilter(efKey, nodeKey);
+
+ JpaToscaEventFilter tdtClone0 = new JpaToscaEventFilter(tef);
new JpaToscaEventFilter().clean();
tef.clean();
assertEquals(tdtClone0, tef);
- assertFalse(new JpaToscaEventFilter().validate(new PfValidationResult()).isValid());
- assertTrue(tef.validate(new PfValidationResult()).isValid());
+ assertFalse(new JpaToscaEventFilter().validate("").isValid());
+ assertTrue(tef.validate("").isValid());
tef.setRequirement(null);
- assertTrue(tef.validate(new PfValidationResult()).isValid());
+ assertTrue(tef.validate("").isValid());
tef.setRequirement("");
- assertFalse(tef.validate(new PfValidationResult()).isValid());
+ assertFalse(tef.validate("").isValid());
tef.setRequirement(A_REQUREMENT);
- assertTrue(tef.validate(new PfValidationResult()).isValid());
+ assertTrue(tef.validate("").isValid());
tef.setCapability(null);
- assertTrue(tef.validate(new PfValidationResult()).isValid());
+ assertTrue(tef.validate("").isValid());
tef.setCapability("");
- assertFalse(tef.validate(new PfValidationResult()).isValid());
+ assertFalse(tef.validate("").isValid());
tef.setCapability(A_CAPABILITY);
- assertTrue(tef.validate(new PfValidationResult()).isValid());
+ assertTrue(tef.validate("").isValid());
tef.setNode(null);
- assertFalse(tef.validate(new PfValidationResult()).isValid());
+ assertFalse(tef.validate("").isValid());
tef.setNode(PfConceptKey.getNullKey());
- assertFalse(tef.validate(new PfValidationResult()).isValid());
+ assertFalse(tef.validate("").isValid());
tef.setNode(nodeKey);
- assertTrue(tef.validate(new PfValidationResult()).isValid());
+ assertTrue(tef.validate("").isValid());
- assertThatThrownBy(() -> tef.validate(null)).hasMessageMatching("resultIn is marked .*on.*ull but is null");
+ assertThatThrownBy(() -> tef.validate(null)).hasMessageMatching("fieldName is marked .*on.*ull but is null");
}
}