Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ public ResponseEntity<ApiResponse> publishCbPlan(
@GetMapping("/read/{cbPlanId}")
public ResponseEntity<ApiResponse> readCbPlan(
@PathVariable("cbPlanId") String cbPlanId,
@RequestHeader(Constants.X_AUTH_TOKEN) String token,
@RequestHeader(Constants.X_AUTH_USER_ORG_ID) String userOrgId) {

ApiResponse response = cbPlanService.readCbPlan(cbPlanId, userOrgId, token);
ApiResponse response = cbPlanService.readCbPlan(cbPlanId, userOrgId);
return new ResponseEntity<>(response, response.getResponseCode());
}

Expand Down Expand Up @@ -114,4 +113,4 @@ public ResponseEntity<ApiResponse> getPrivateCBPlanListForUser(
ApiResponse response = cbPlanLearnerService.getCBPlanCourseListForUser(userId,userOrgId);
return new ResponseEntity<>(response, response.getResponseCode());
}
}
}
8 changes: 4 additions & 4 deletions src/main/java/com/igot/cb/service/CbPlanServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public ApiResponse publishCbPlan(ApiRequest request, String userOrgId, String au
requestValidator.validateContextData(existingCbPlan, isCCA, userOrgId, existingRootOrgIdsInCriteria);
// Need to update live plan with draft data if any
// Need to update lookup table entries
updatedRequest.putAll(prepareCbPlanForRePublish(existingCbPlan, incomingRequest, userId));
updatedRequest.putAll(prepareCbPlanForRePublish(existingCbPlan, incomingRequest));
if (updatedRequest.containsKey(Constants.CONTEXT_DATA_REQUEST)) {
errors = requestValidator.validateContextData(updatedRequest, isCCA, userOrgId, rootOrgIdsInCriteria);
}
Expand Down Expand Up @@ -520,7 +520,7 @@ public Date parseToDate(Object endDateObj) {
return null;
}

public ApiResponse readCbPlan(String cbPlanId, String userOrgId, String authUserToken) {
public ApiResponse readCbPlan(String cbPlanId, String userOrgId) {
ApiResponse response = ProjectUtil.createDefaultResponse(Constants.API_CB_PLAN_READ_BY_ID);
try {
if (StringUtils.isEmpty(cbPlanId)) {
Expand Down Expand Up @@ -820,7 +820,7 @@ private Map<String, Object> prepareCbPlanForUpdate(Map<String, Object> incomingR
}

private Map<String, Object> prepareCbPlanForRePublish(Map<String, Object> existingCbPlan,
Map<String, Object> incomingRequest, String userId) throws JsonProcessingException {
Map<String, Object> incomingRequest) throws JsonProcessingException {
Map<String, Object> dataInDraftObject = existingCbPlan.get(Constants.DRAFT_DATA) != null
? mapper.readValue((String) existingCbPlan.get(Constants.DRAFT_DATA),
new TypeReference<Map<String, Object>>() {
Expand Down Expand Up @@ -1048,4 +1048,4 @@ private void handleUpdateOfLiveCbPlan(ApiResponse response, Map<String, Object>
response.setResponseCode(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ void testReadCbPlan() throws Exception {
content.put(Constants.ID, "plan123");
mockResponse.getResult().put(Constants.CONTENT, content);

when(cbPlanService.readCbPlan(anyString(), anyString(), anyString())).thenReturn(mockResponse);
when(cbPlanService.readCbPlan(anyString(), anyString())).thenReturn(mockResponse);

ResponseEntity<ApiResponse> response = controller.readCbPlan("plan123", "token", "orgId");
ResponseEntity<ApiResponse> response = controller.readCbPlan("plan123", "orgId");

assertEquals(HttpStatus.OK, response.getStatusCode());
assertEquals(Constants.SUCCESS, response.getBody().getParams().getStatus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,15 @@ void searchCbPlan_whenEsThrows_raises() throws Exception {

@Test
void readCbPlan_emptyId_badRequest() {
ApiResponse r = cbPlanService.readCbPlan("", "org", "token");
ApiResponse r = cbPlanService.readCbPlan("", "org");
assertEquals(HttpStatus.BAD_REQUEST, r.getResponseCode());
}

@Test
void readCbPlan_whenDbThrows_internalError() {
when(cassandraOperation.getRecordsByProperties(anyString(), anyString(), anyMap(), any(), any()))
.thenThrow(new RuntimeException("db"));
ApiResponse r = cbPlanService.readCbPlan("id1", "org", "token");
ApiResponse r = cbPlanService.readCbPlan("id1", "org");
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, r.getResponseCode());
}

Expand Down Expand Up @@ -322,7 +322,7 @@ void testPrepareCbPlanForRePublish() throws Exception {

Map<String, Object> result =
ReflectionTestUtils.invokeMethod(cbPlanService, "prepareCbPlanForRePublish",
existingCbPlan, incomingRequest, "user123");
existingCbPlan, incomingRequest);

assertNotNull(result);
assertEquals(true, result.get(Constants.IS_APAR));
Expand Down Expand Up @@ -743,4 +743,4 @@ void testUpdateCbPlan_success() throws Exception {
assertEquals(HttpStatus.OK, response.getResponseCode());
}

}
}
10 changes: 5 additions & 5 deletions src/test/java/com/igot/cb/service/CbPlanServiceImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ void testReadCbPlan_Success() {

when(contentService.readContent(anyString(), any())).thenReturn(createMockContent());

ApiResponse response = cbPlanService.readCbPlan("planId", "orgId", "token");
ApiResponse response = cbPlanService.readCbPlan("planId", "orgId");

assertNotNull(response);
}
Expand Down Expand Up @@ -1464,7 +1464,7 @@ void testReadCbPlan_NotFound() {
when(cassandraOperation.getRecordsByProperties(anyString(), anyString(), any(), any(), any()))
.thenReturn(new ArrayList<>());

ApiResponse response = cbPlanService.readCbPlan("planId", "orgId", "token");
ApiResponse response = cbPlanService.readCbPlan("planId", "orgId");

assertEquals(Constants.FAILED, response.getParams().getStatus());
assertEquals(HttpStatus.BAD_REQUEST, response.getResponseCode());
Expand All @@ -1484,7 +1484,7 @@ void testReadCbPlan_ContentError() {
when(contentService.readContent(anyString(), any()))
.thenThrow(new RuntimeException("Content service error"));

ApiResponse response = cbPlanService.readCbPlan("planId", "orgId", "token");
ApiResponse response = cbPlanService.readCbPlan("planId", "orgId");

assertEquals(Constants.FAILED, response.getParams().getStatus());
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getResponseCode());
Expand Down Expand Up @@ -1585,11 +1585,11 @@ void testSearchCbPlan_ExceptionPath() throws Exception {

@Test
void testReadCbPlan_EmptyAndErrorPaths() {
ApiResponse r1 = cbPlanService.readCbPlan("", "org", "t");
ApiResponse r1 = cbPlanService.readCbPlan("", "org");
assertEquals(HttpStatus.BAD_REQUEST, r1.getResponseCode());
when(cassandraOperation.getRecordsByProperties(anyString(), anyString(), anyMap(), any(), any()))
.thenThrow(new RuntimeException("fail"));
ApiResponse r2 = cbPlanService.readCbPlan("id", "org", "t");
ApiResponse r2 = cbPlanService.readCbPlan("id", "org");
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, r2.getResponseCode());
}

Expand Down