* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
/**
* Common base class for request tests.
*/
-public class CommonRequestBase {
+@SuppressWarnings({"unchecked", "rawtypes"})
+public class CommonRequestBase { // NOSONAR - class is being extended by other test classes
protected static final String PDP1 = "pdp_1";
protected static final String PDP2 = "pdp_2";
protected static final String PDP3 = "pdp_3";
protected PdpModifyRequestMapParams mapParams;
@BeforeAll
- public static void setupBeforeAll() {
+ public static void setupBeforeAll() { // NOSONAR - class is being extended by other test classes
Registry.registerOrReplace(PapConstants.REG_METER_REGISTRY, new SimpleMeterRegistry());
}
* @throws Exception if an error occurs
*/
@BeforeEach
- @SuppressWarnings("unchecked")
- public void setUp() throws Exception {
+ public void setUp() throws Exception { // NOSONAR - class is being extended by other test classes
publisher = mock(Publisher.class);
notifier = mock(PolicyNotifier.class);
dispatcher = mock(RequestIdDispatcher.class);
*
* @param response the response to pass to the listener
*/
- @SuppressWarnings("unchecked")
protected void invokeProcessResponse(PdpStatus response) {
- @SuppressWarnings("rawtypes")
ArgumentCaptor<TypedMessageListener> processResp = ArgumentCaptor.forClass(TypedMessageListener.class);
verify(dispatcher).register(any(), processResp.capture());
/**
* Gets the timeout handler that was registered with the timer manager and invokes it.
*/
- @SuppressWarnings("unchecked")
protected void invokeTimeoutHandler() {
- @SuppressWarnings("rawtypes")
ArgumentCaptor<Consumer> timeoutHdlr = ArgumentCaptor.forClass(Consumer.class);
verify(timers).register(any(), timeoutHdlr.capture());
* Makes an update request with a new message.
*
* @param pdpName PDP name
- * @param group group name
- * @param subgroup subgroup name
* @return a new update request
*/
- protected UpdateReq makeUpdateReq(String pdpName, String group, String subgroup) {
+ protected UpdateReq makeUpdateReq(String pdpName) {
UpdateReq req = mock(UpdateReq.class);
when(req.getName()).thenReturn(MY_REQ_NAME);
- when(req.getMessage()).thenReturn(makeUpdate(pdpName, group, subgroup));
+ when(req.getMessage()).thenReturn(
+ makeUpdate(pdpName));
return req;
}
* Makes an update message.
*
* @param pdpName PDP name
- * @param group group name
- * @param subgroup subgroup name
* @return a new update message
*/
- protected PdpUpdate makeUpdate(String pdpName, String group, String subgroup) {
+ protected PdpUpdate makeUpdate(String pdpName) {
PdpUpdate message = new PdpUpdate();
message.setName(pdpName);
message.setPoliciesToBeDeployed(Collections.emptyList());
message.setPoliciesToBeUndeployed(Collections.emptyList());
- message.setPdpGroup(group);
- message.setPdpSubgroup(subgroup);
+ message.setPdpGroup(CommonRequestBase.MY_GROUP);
+ message.setPdpSubgroup(CommonRequestBase.MY_SUBGROUP);
return message;
}
/**
* Makes a state-change request with a new message.
*
- * @param pdpName PDP name
- * @param state desired PDP state
* @return a new state-change request
*/
- protected StateChangeReq makeStateChangeReq(String pdpName, PdpState state) {
+ protected StateChangeReq makeStateChangeReq() {
StateChangeReq req = mock(StateChangeReq.class);
when(req.getName()).thenReturn(MY_REQ_NAME);
- when(req.getMessage()).thenReturn(makeStateChange(pdpName, state));
+ when(req.getMessage()).thenReturn(makeStateChange(CommonRequestBase.PDP1));
return req;
}
* Makes a state-change message.
*
* @param pdpName PDP name
- * @param state desired PDP state
* @return a new state-change message
*/
- protected PdpStateChange makeStateChange(String pdpName, PdpState state) {
+ protected PdpStateChange makeStateChange(String pdpName) {
PdpStateChange message = new PdpStateChange();
message.setName(pdpName);
- message.setState(state);
+ message.setState(CommonRequestBase.MY_STATE);
return message;
}
* ONAP PAP
* ================================================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020-2021, 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021, 2023-2025 OpenInfra Foundation Europe.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
response = new PdpStatus();
- update = makeUpdate(PDP1, MY_GROUP, MY_SUBGROUP);
- change = makeStateChange(PDP1, MY_STATE);
+ update = makeUpdate(PDP1);
+ change = makeStateChange(PDP1);
when(requests.getPdpName()).thenReturn(PDP1);
when(requests.isFirstInQueue(any())).thenReturn(true);
getSingletons(1);
// add another request with the same PDP
- map.addRequest(makeStateChange(PDP1, MY_STATE));
+ map.addRequest(makeStateChange(PDP1));
assertEquals(1, map.nalloc);
// should now have another singleton
// add another request with a different PDP
- map.addRequest(makeStateChange(DIFFERENT, MY_STATE));
+ map.addRequest(makeStateChange(DIFFERENT));
// should now have another allocation
assertEquals(2, map.nalloc);
* ONAP PAP
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@Override
@BeforeEach
public void setUp() {
- update = makeUpdateReq(PDP1, MY_GROUP, MY_SUBGROUP);
- change = makeStateChangeReq(PDP1, MY_STATE);
+ update = makeUpdateReq(PDP1);
+ change = makeStateChangeReq();
data = new PdpRequests(PDP1, notifier);
}
data.addSingleton(update);
// add duplicate update
- UpdateReq req2 = makeUpdateReq(PDP1, MY_GROUP, MY_SUBGROUP);
+ UpdateReq req2 = makeUpdateReq(PDP1);
data.addSingleton(req2);
// should not publish duplicate
data.addSingleton(change);
// add duplicate requests
- StateChangeReq change2 = makeStateChangeReq(PDP1, MY_STATE);
+ StateChangeReq change2 = makeStateChangeReq();
when(change.reconfigure(change2.getMessage())).thenReturn(true);
data.addSingleton(change2);
- UpdateReq update2 = makeUpdateReq(PDP1, MY_GROUP, MY_SUBGROUP);
+ UpdateReq update2 = makeUpdateReq(PDP1);
when(update.reconfigure(update2.getMessage())).thenReturn(true);
data.addSingleton(update2);
@Test
void testAddSingleton_Broadcast() {
- UpdateReq req = makeUpdateReq(null, MY_GROUP, MY_SUBGROUP);
+ UpdateReq req = makeUpdateReq(null);
assertThatIllegalArgumentException().isThrownBy(() -> data.addSingleton(req))
.withMessage("unexpected broadcast for pdp_1");
}