@Setter
@ToString
@NoArgsConstructor
-public class ParticipantMessage {
+public abstract class ParticipantMessage {
@Setter(AccessLevel.NONE)
private ParticipantMessageType messageType;
*
* @param messageType the message type
*/
- public ParticipantMessage(final ParticipantMessageType messageType) {
+ protected ParticipantMessage(final ParticipantMessageType messageType) {
this.messageType = messageType;
}
*
* @param source source from which to copy
*/
- public ParticipantMessage(final ParticipantMessage source) {
+ protected ParticipantMessage(final ParticipantMessage source) {
this.messageId = source.messageId;
this.timestamp = source.timestamp;
this.messageType = source.messageType;
private Timestamp lastMsg = TimestampHelper.nowTimestamp();
@Column(length = 100000)
- @Convert(converter = StringToDocMessage.class)
+ @Convert(converter = StringToDocMessageConverter.class)
@NotNull
private DocMessage docMessage;
import org.onap.policy.clamp.models.acm.document.concepts.DocMessage;
@Converter(autoApply = true)
-public class StringToDocMessage extends AbstractConverter implements AttributeConverter<DocMessage, String> {
+public class StringToDocMessageConverter extends AbstractConverter implements AttributeConverter<DocMessage, String> {
@Override
public String convertToDatabaseColumn(DocMessage docMessage) {
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021-2026 OpenInfra Foundation Europe. 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.models.acm;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+import org.junit.jupiter.api.Test;
+import org.onap.policy.common.utils.test.PojoTester;
+
+/**
+ * Class to perform unit tests of all pojos.
+ */
+class PojosTest {
+
+ @Test
+ void testConceptsPojos() {
+ assertDoesNotThrow(() -> PojoTester.testPojos(getClass().getPackageName() + ".concepts"));
+ }
+
+ @Test
+ void testDocumentPojos() {
+ assertDoesNotThrow(() -> PojoTester.testPojos(getClass().getPackageName() + ".document.concepts"));
+ }
+
+ @Test
+ void testPersistencePojos() {
+ assertDoesNotThrow(() -> PojoTester.testPojos(getClass().getPackageName() + ".persistence.concepts"));
+ }
+
+ @Test
+ void testMessagesPojos() {
+ assertDoesNotThrow(() -> PojoTester.testPojos(getClass().getPackageName() + ".messages"));
+ }
+
+}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.concepts;
-
-import com.openpojo.reflection.PojoClass;
-import com.openpojo.reflection.impl.PojoClassFactory;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.rule.impl.EqualsAndHashCodeMatchRule;
-import com.openpojo.validation.rule.impl.GetterMustExistRule;
-import com.openpojo.validation.rule.impl.NoPublicFieldsExceptStaticFinalRule;
-import com.openpojo.validation.rule.impl.SetterMustExistRule;
-import com.openpojo.validation.test.impl.GetterTester;
-import com.openpojo.validation.test.impl.SetterTester;
-import java.util.List;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.common.utils.test.ToStringTester;
-
-/**
- * Class to perform unit tests of all pojos.
- */
-class AutomationCompositionConceptPojosTest {
-
- @Test
- void testPojos() {
- List<PojoClass> pojoClasses =
- PojoClassFactory.getPojoClasses(AutomationCompositionConceptPojosTest.class.getPackageName());
-
- // @formatter:off
- final Validator validator = ValidatorBuilder
- .create()
- .with(new SetterMustExistRule())
- .with(new GetterMustExistRule())
- .with(new EqualsAndHashCodeMatchRule())
- .with(new NoPublicFieldsExceptStaticFinalRule())
- .with(new SetterTester())
- .with(new GetterTester())
- .with(new ToStringTester())
- .build();
-
- validator.validate(pojoClasses);
- // @formatter:on
- }
-}
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2021-2026 OpenInfra Foundation Europe. 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.
@Test
void testCopyConstructor() throws CoderException {
- assertThatThrownBy(() -> new ParticipantMessage((ParticipantMessage) null))
+ assertThatThrownBy(() -> new TestParticipantMessage(null))
.isInstanceOf(NullPointerException.class);
// verify with null values
- var message = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE);
- var newmsg = new ParticipantMessage(message);
+ var message = new TestParticipantMessage();
+ var newmsg = new TestParticipantMessage(message);
newmsg.setMessageId(message.getMessageId());
newmsg.setTimestamp(message.getTimestamp());
assertEquals(message.toString(), newmsg.toString());
// verify with all values
message = makeMessage();
- newmsg = new ParticipantMessage(message);
+ newmsg = new TestParticipantMessage(message);
newmsg.setMessageId(message.getMessageId());
newmsg.setTimestamp(message.getTimestamp());
assertEquals(message.toString(), newmsg.toString());
- assertSerializable(message, ParticipantMessage.class);
+ assertSerializable(message, TestParticipantMessage.class);
}
@Test
assertFalse(message.appliesTo(CommonTestData.getParticipantId(), CommonTestData.getReplicaId()));
}
- private ParticipantMessage makeMessage() {
- var msg = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE);
+ private TestParticipantMessage makeMessage() {
+ var msg = new TestParticipantMessage();
msg.setParticipantId(CommonTestData.getParticipantId());
msg.setMessageId(UUID.randomUUID());
return msg;
}
+
+ private static class TestParticipantMessage extends ParticipantMessage {
+ public TestParticipantMessage() {
+ super(ParticipantMessageType.PARTICIPANT_STATE_CHANGE);
+ }
+
+ public TestParticipantMessage(ParticipantMessage source) {
+ super(source);
+ }
+ }
}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2024 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.messages.kafka.participant;
-
-import com.openpojo.reflection.impl.PojoClassFactory;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.rule.impl.GetterMustExistRule;
-import com.openpojo.validation.rule.impl.SetterMustExistRule;
-import com.openpojo.validation.test.impl.GetterTester;
-import com.openpojo.validation.test.impl.SetterTester;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.common.utils.test.ToStringTester;
-
-/**
- * Class to perform unit tests of all pojos.
- */
-class ParticipantPojosTest {
-
- @Test
- void testPojos() {
- var pojoClasses =
- PojoClassFactory.getPojoClasses(ParticipantPojosTest.class.getPackageName());
-
- pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessage.class));
- pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessageTest.class));
- pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessage.class));
- pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessageTest.class));
- pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionDeployAck.class));
- pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionDeployAckTest.class));
-
- // @formatter:off
- final var validator = ValidatorBuilder
- .create()
- .with(new ToStringTester())
- .with(new SetterMustExistRule())
- .with(new GetterMustExistRule())
- .with(new SetterTester())
- .with(new GetterTester())
- .build();
-
- validator.validate(pojoClasses);
- // @formatter:on
- }
-}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.messages.rest;
-
-import com.openpojo.reflection.PojoClass;
-import com.openpojo.reflection.impl.PojoClassFactory;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.rule.impl.GetterMustExistRule;
-import com.openpojo.validation.rule.impl.SetterMustExistRule;
-import com.openpojo.validation.test.impl.GetterTester;
-import com.openpojo.validation.test.impl.SetterTester;
-import java.util.List;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.common.utils.test.ToStringTester;
-
-/**
- * Class to perform unit tests of all pojos.
- */
-class MessagesRestPojosTest {
-
- @Test
- void testPojos() {
- List<PojoClass> pojoClasses =
- PojoClassFactory.getPojoClassesRecursively(MessagesRestPojosTest.class.getPackageName(), null);
-
-
- // @formatter:off
- final Validator validator = ValidatorBuilder
- .create()
- .with(new ToStringTester())
- .with(new SetterMustExistRule())
- .with(new GetterMustExistRule())
- .with(new SetterTester())
- .with(new GetterTester())
- .build();
-
- validator.validate(pojoClasses);
- // @formatter:on
- }
-}
import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageType;
import org.onap.policy.models.base.PfModelRuntimeException;
-class StringToDocMessageTest {
+class StringToDocMessageConverterTest {
@Test
void testConvert() {
- var stringToDocMessage = new StringToDocMessage();
+ var stringToDocMessage = new StringToDocMessageConverter();
var docMessage = new DocMessage();
docMessage.setMessageId(UUID.randomUUID().toString());
docMessage.setInstanceId(UUID.randomUUID());
@Test
void testNull() {
- var stringToDocMessage = new StringToDocMessage();
+ var stringToDocMessage = new StringToDocMessageConverter();
var dbData = stringToDocMessage.convertToDatabaseColumn(null);
assertThat(dbData).isNull();
var map = stringToDocMessage.convertToEntityAttribute(null);
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2021-2026 OpenInfra Foundation Europe. 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 org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantAckMessage;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantDeregister;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantDeregisterAck;
-import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessage;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageType;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantPrime;
import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantRegister;
var participantAckMsg = new ParticipantAckMessage(ParticipantMessageType.AUTOMATION_COMPOSITION_DEPLOY);
assertTrue(participantHandler.appliesTo(participantAckMsg));
- var participantMsg = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATUS);
+ var participantMsg = new ParticipantStatus();
assertTrue(participantHandler.appliesTo(participantMsg));
participantMsg.setParticipantId(UUID.randomUUID());
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2026 OpenInfra Foundation Europe. 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.
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.models.acm.persistence.concepts;
+package org.onap.policy.common.utils.test;
-import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.filters.FilterNonConcrete;
import com.openpojo.reflection.impl.PojoClassFactory;
import com.openpojo.validation.Validator;
import com.openpojo.validation.ValidatorBuilder;
import com.openpojo.validation.rule.impl.SetterMustExistRule;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
-import java.util.List;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.common.utils.test.ToStringTester;
+import lombok.NoArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
/**
- * Class to perform unit tests of all pojos.
+ * Utility class for testing POJO classes using OpenPojo validation framework.
+ * Validates getter/setter methods, equals/hashCode contracts, and other POJO conventions.
*/
-class PojosTest {
+@Slf4j
+@NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
+public class PojoTester {
- @Test
- void testPojos() {
- List<PojoClass> pojoClasses =
- PojoClassFactory.getPojoClasses(PojosTest.class.getPackageName());
+ /**
+ * Tests all POJOs in the specified package using default exclusion pattern.
+ *
+ * @param packageName the package to scan for POJO classes
+ */
+ public static void testPojos(String packageName) {
+ testPojos(packageName, ".*(Test|Utils|Converter|Comparator)$");
+ }
+
+ /**
+ * Tests all POJOs in the specified package, excluding classes matching the pattern.
+ *
+ * @param packageName the package to scan for POJO classes
+ * @param excludePattern regex pattern for class names to exclude
+ */
+ public static void testPojos(String packageName, String excludePattern) {
+ var pojoClasses = PojoClassFactory.getPojoClassesRecursively(packageName, new FilterNonConcrete());
+ pojoClasses.removeIf(clazz -> clazz.getName().matches(excludePattern));
+ if (pojoClasses.isEmpty()) {
+ throw new IllegalArgumentException("No POJO classes found in package: " + packageName);
+ }
+ pojoClasses.forEach(clazz -> log.info("Testing class: {}", clazz.getName()));
- // @formatter:off
final Validator validator = ValidatorBuilder
.create()
.with(new SetterMustExistRule())
.with(new GetterTester())
.with(new ToStringTester())
.build();
-
validator.validate(pojoClasses);
- // @formatter:on
}
}
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2026 OpenInfra Foundation Europe. 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.openpojo.validation.affirm.Affirm;
import com.openpojo.validation.test.Tester;
import com.openpojo.validation.utils.ValidationHelper;
+import java.util.regex.Pattern;
import lombok.AllArgsConstructor;
import org.hamcrest.Matcher;
-
/**
* Class to provide toString testing utility for testing pojo classes.
*
matcher = anything();
}
- @SuppressWarnings("unchecked")
@Override
public void run(final PojoClass pojoClass) {
final Class<?> clazz = pojoClass.getClazz();
if (anyOf(matcher).matches(clazz)) {
final Object classInstance = ValidationHelper.getBasicInstance(pojoClass);
- Affirm.affirmFalse("Found default toString output",
- classInstance.toString().matches(Object.class.getName() + "@" + "\\w+"));
+ Affirm.affirmFalse("Class [" + clazz.getName()
+ + "] uses default Object.toString() - please implement a proper toString() method",
+ classInstance.toString().matches(Pattern.quote(clazz.getName()) + "@[0-9a-fA-F]+"));
}
}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2026 OpenInfra Foundation Europe. 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.utils.test;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.Test;
+
+class PojoTesterTest {
+
+ private static final String BASE_PACKAGE = PojoTesterTest.class.getPackageName();
+
+ @Test
+ void testValidPojo() {
+ assertDoesNotThrow(() -> PojoTester.testPojos(BASE_PACKAGE + ".pojo.valid"));
+ }
+
+ @Test
+ void testInvalidPojo() {
+ assertThrows(AssertionError.class, () -> PojoTester.testPojos(BASE_PACKAGE + ".pojo.invalid"));
+ }
+
+ @Test
+ void testEmptyPackage() {
+ assertThrows(Exception.class, () -> PojoTester.testPojos(BASE_PACKAGE + ".pojo.empty"));
+ }
+
+ @Test
+ void testNonExistingPackage() {
+ assertThrows(Exception.class, () -> PojoTester.testPojos(BASE_PACKAGE + ".pojo.nonexistent"));
+ }
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2026 OpenInfra Foundation Europe. 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.utils.test;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import com.openpojo.reflection.impl.PojoClassFactory;
+import lombok.ToString;
+import org.junit.jupiter.api.Test;
+
+class ToStringTesterTest {
+
+ @Test
+ void testGoodToString() {
+ final ToStringTester tester = new ToStringTester();
+ final var pojoClass = PojoClassFactory.getPojoClass(GoodToStringClass.class);
+ assertDoesNotThrow(() -> tester.run(pojoClass));
+ }
+
+ @Test
+ void testDefaultToString() {
+ final ToStringTester tester = new ToStringTester();
+ final var pojoClass = PojoClassFactory.getPojoClass(DefaultToStringClass.class);
+ assertThrows(AssertionError.class, () -> tester.run(pojoClass));
+ }
+
+ @ToString
+ static class GoodToStringClass {
+ String myField;
+ }
+
+ static class DefaultToStringClass {
+ }
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2026 OpenInfra Foundation Europe. 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.utils.test.pojo.empty;
+
+public enum NotAPojo {
+ DUMMY
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2026 OpenInfra Foundation Europe. 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.utils.test.pojo.invalid;
+
+public class InvalidPojo {
+ public String name; // Public field violates rule
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2026 OpenInfra Foundation Europe. 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.utils.test.pojo.valid;
+
+import lombok.Data;
+
+@Data
+public class ValidPojo {
+ private String name;
+ private int value;
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2026 OpenInfra Foundation Europe. 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+import org.junit.jupiter.api.Test;
+import org.onap.policy.common.utils.test.PojoTester;
+
+class PojosTest {
+
+ @Test
+ void testErrorConceptsPojos() {
+ assertDoesNotThrow(() -> PojoTester.testPojos(getClass().getPackageName() + ".errors.concepts"));
+ }
+
+ @Test
+ void testToscaConceptsPojos() {
+ assertDoesNotThrow(() -> PojoTester.testPojos(getClass().getPackageName() + ".tosca.authorative.concepts"));
+ }
+
+}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Decision Models
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.errors.concepts;
-
-import com.openpojo.reflection.filters.FilterPackageInfo;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.test.impl.GetterTester;
-import com.openpojo.validation.test.impl.SetterTester;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.common.utils.test.ToStringTester;
-
-class TestModels {
-
- @Test
- void testDecisionModels() {
- final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterTester())
- .with(new GetterTester()).build();
- validator.validate(TestModels.class.getPackage().getName(), new FilterPackageInfo());
- }
-
-
-}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy Model
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021-2025 OpenInfra Foundation Europe. 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca.authorative.concepts;
-
-import com.openpojo.reflection.filters.FilterClassName;
-import com.openpojo.reflection.filters.FilterPackageInfo;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.rule.impl.GetterMustExistRule;
-import com.openpojo.validation.rule.impl.SetterMustExistRule;
-import com.openpojo.validation.test.impl.GetterTester;
-import com.openpojo.validation.test.impl.SetterTester;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.common.utils.test.ToStringTester;
-
-/**
- * Class to perform unit tests of all pojos.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- *
- */
-class PojosTest {
-
- private static final String POJO_PACKAGE = "org.onap.policy.models.tosca.authorative.concepts";
-
- @Test
- void testPojos() {
- // @formatter:off
- final Validator validator = ValidatorBuilder
- .create()
- .with(new ToStringTester())
- .with(new SetterMustExistRule())
- .with(new GetterMustExistRule())
- .with(new SetterTester())
- .with(new GetterTester())
- .build();
- validator.validate(POJO_PACKAGE,
- new FilterPackageInfo(),
- new FilterClassName(ToscaIdentifierTestBase.class.getName()),
- new FilterClassName(".*Test$")
- );
- // @formatter:on
- }
-}
*
* @param <T> type of key being tested
*/
-class ToscaIdentifierTestBase<T extends Comparable<T>> {
+abstract class ToscaIdentifierTestBase<T extends Comparable<T>> {
public static final String NAME = "my-name";
public static final String VERSION = "1.2.3";