}
// try to reconfigure an existing request with the new message
- //
- // don't reconfigure the first request
PdpMessage newMessage = request.getMessage();
- int count = 0;
for (Request req : requests) {
- if (count++ > 0 && req.reconfigure(newMessage)) {
+ if (req.reconfigure(newMessage)) {
return;
}
}
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-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.
return;
}
+ /*
+ * Note: don't have to verify that getResponse() != null, as this code won't
+ * even be reached if that's the case.
+ */
+ if (!message.getRequestId().equals(response.getResponse().getResponseTo())) {
+ logger.info("{} ignore old response via {} {}: {}", getName(), infra, topic,
+ response.getResponse().getResponseTo());
+ return;
+ }
+
svcmgr.stop();
String reason = checkResponse(response);
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.models.pdp.concepts.PdpMessage;
+import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
msg = new PdpStateChange();
response.setName(PDP1);
+ response.setResponse(new PdpResponseDetails());
+ response.getResponse().setResponseTo(msg.getRequestId());
msg.setName(PDP1);
req = new MyRequest(reqParams, MY_REQ_NAME, msg);
verify(listener, never()).failure(any(), any());
}
+ @Test
+ public void testProcessResponse_WrongRequest() {
+ req.startPublishing();
+
+ response.getResponse().setResponseTo(DIFFERENT);
+
+ invokeProcessResponse(response);
+
+ verify(listener, never()).success(any());
+ verify(listener, never()).failure(any(), any());
+ verify(timer, never()).cancel();
+ }
+
@Test
public void testProcessResponse_ResponseFailed() {
req.startPublishing();