Skip to content

Commit 130f578

Browse files
tobiasakeemichaf
authored andcommitted
HTTPStatus should be Ok even if subscription is not found. HTTPStatus is more about the HTTP communication, not about the Database status. (#19)
* Fix updateSubscription RestApi issue that prevented subscription to be updated. * Changed name on isDuplicateSubscriptions functions to doSubscriptionExist. Fixed impacted unit test due to this change. * Simplified updateSubscription RestApi, so SubscritionName is only specified in json file/object. * HTTPStatus should be Ok even if subscription is not found. HTTPStatus is more about the HTTP communication, not about the Database status.
1 parent 654a592 commit 130f578

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/com/ericsson/ei/controller/SubscriptionControllerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public ResponseEntity<Subscription> getSubscriptionById(@PathVariable String sub
6969
return new ResponseEntity<Subscription>(subscription, HttpStatus.OK);
7070
} catch (SubscriptionNotFoundException e) {
7171
LOG.error("Subscription :" + subscriptionName + " not found in records");
72-
return new ResponseEntity<Subscription>(subscription, HttpStatus.NOT_FOUND);
72+
return new ResponseEntity<Subscription>(subscription, HttpStatus.OK);
7373
}
7474

7575
}
@@ -124,7 +124,7 @@ public ResponseEntity<List<Subscription>> getSubscriptions() {
124124
return new ResponseEntity<List<Subscription>>(subscriptionList, HttpStatus.OK);
125125
} catch (SubscriptionNotFoundException e) {
126126
LOG.error(e.getLocalizedMessage());
127-
return new ResponseEntity<List<Subscription>>(subscriptionList, HttpStatus.NOT_FOUND);
127+
return new ResponseEntity<List<Subscription>>(subscriptionList, HttpStatus.OK);
128128
}
129129
}
130130
}

src/test/java/com/ericsson/ei/subscription/SubscriptionRestAPITest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void getSubScriptionByNameNotFound() throws Exception {
124124

125125
MvcResult result = mockMvc.perform(requestBuilder).andReturn();
126126

127-
assertEquals(HttpStatus.NOT_FOUND.value(), result.getResponse().getStatus());
127+
assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus());
128128
assertEquals("", result.getResponse().getContentAsString());
129129
}
130130

0 commit comments

Comments
 (0)