Exception scenario handling 92/127992/1
authormpriyank <priyank.maheshwari@est.tech>
Wed, 23 Mar 2022 09:50:10 +0000 (15:20 +0530)
committermpriyank <priyank.maheshwari@est.tech>
Wed, 23 Mar 2022 10:01:32 +0000 (15:31 +0530)
- Updated logic to throw exception when response code is not
  2XX, previously it was checking for 201 CREATED

Issue-ID: CPS-955
Change-Id: I45cc53cf5b0e603755a75dbd089ead0eb87e5970
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java

index 4f12622..38b044d 100644 (file)
@@ -134,7 +134,7 @@ public class DmiServiceImpl implements DmiService {
                 "Parsing error occurred while converting given cm-handles object list to JSON ");
         }
         final ResponseEntity<String> responseEntity = ncmpRestClient.registerCmHandlesWithNcmp(cmHandlesJson);
-        if ((responseEntity.getStatusCode() != HttpStatus.CREATED)) {
+        if (!responseEntity.getStatusCode().is2xxSuccessful()) {
             throw new CmHandleRegistrationException(responseEntity.getBody());
         }
     }