play.test.Helpers Java Examples
The following examples show how to use
play.test.Helpers.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserSkillEndorsementControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testAddSkillEndorsement() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(JsonKey.USER_ID, "{userId} uuiuhcf784508 8y8c79-fhh"); innerMap.put(JsonKey.ENDORSED_USER_ID, "1223"); innerMap.put(JsonKey.SKILL_NAME, "C"); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); Http.RequestBuilder req = new Http.RequestBuilder().bodyJson(json).uri("/v1/user/skill/endorse/add").method("POST"); //req.headers(headerMap); Result result = Helpers.route(application,req); assertEquals(200, result.status()); }
Example #2
Source File: LocationControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testCreateLocationWithoutType() { Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> locationData = new HashMap<>(); locationData.put(JsonKey.NAME, LOCATION_NAME); locationData.put(JsonKey.CODE, LOCATION_CODE); requestMap.put(JsonKey.REQUEST, locationData); String data = TestUtil.mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri(CREATE_LOCATION_URL).method("POST"); //req.headers(headerMap); Result result = Helpers.route(application,req); assertEquals(400, result.status()); }
Example #3
Source File: BadgeAssertionControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void revokeAssertionTest() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(BadgingJsonKey.ASSERTION_ID, "assertionId"); innerMap.put(BadgingJsonKey.RECIPIENT_ID, "userIdorcontentId"); innerMap.put(BadgingJsonKey.RECIPIENT_TYPE, "user"); innerMap.put(BadgingJsonKey.REVOCATION_REASON, "some reason"); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder() .bodyJson(json) .uri("/v1/issuer/badge/assertion/delete") .method("DELETE"); Result result = Helpers.route(application, req); assertEquals(200, result.status()); }
Example #4
Source File: OrgTypeControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
public String getResponseCode(Result result) { String responseStr = Helpers.contentAsString(result); ObjectMapper mapper = new ObjectMapper(); try { Response response = mapper.readValue(responseStr, Response.class); if (response != null) { ResponseParams params = response.getParams(); return params.getStatus(); } } catch (Exception e) { ProjectLogger.log( "BaseControllerTest:getResponseCode: Exception occurred with error message = " + e.getMessage(), LoggerEnum.ERROR.name()); } return ""; }
Example #5
Source File: BadgeAssertionControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testAssertionCreate() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(BadgingJsonKey.ISSUER_ID, "issuerId"); innerMap.put(BadgingJsonKey.BADGE_CLASS_ID, "badgeid"); innerMap.put(BadgingJsonKey.RECIPIENT_EMAIL, "[email protected]"); innerMap.put(BadgingJsonKey.RECIPIENT_ID, "userIdorcontentId"); innerMap.put(BadgingJsonKey.RECIPIENT_TYPE, "user"); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/issuer/badge/assertion/create").method("POST"); Result result = Helpers.route(application, req); assertEquals(200, result.status()); }
Example #6
Source File: BadgeAssertionControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void createAssertionWithInvalidData() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(BadgingJsonKey.BADGE_CLASS_ID, "badgeid"); innerMap.put(BadgingJsonKey.RECIPIENT_EMAIL, "[email protected]"); innerMap.put(BadgingJsonKey.RECIPIENT_ID, "userIdorcontentId"); innerMap.put(BadgingJsonKey.RECIPIENT_TYPE, "user"); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/issuer/badge/assertion/create").method("POST"); Result result = Helpers.route(application, req); assertEquals(400, result.status()); }
Example #7
Source File: UserSkillControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test @Ignore public void testUpdateSkill() { Map<String, Object> requestMap = new HashMap(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(JsonKey.USER_ID, "{userId} uuiuhcf784508 8y8c79-fhh"); innerMap.put(JsonKey.SKILLS, Arrays.asList("C", "C++")); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); Http.RequestBuilder req = new Http.RequestBuilder().bodyJson(json).uri("/v1/user/skill/update").method("POST"); //req.headers(headerMap); Result result = Helpers.route(application,req); assertEquals(200, result.status()); }
Example #8
Source File: LocationControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testSearchLocation() { Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> requestBody = new HashMap<>(); Map<String, Object> filters = new HashMap<>(); filters.put(JsonKey.NAME, LOCATION_NAME); filters.put(JsonKey.CODE, LOCATION_CODE); filters.put(GeoLocationJsonKey.LOCATION_TYPE, LOCATION_TYPE); requestBody.put(JsonKey.FILTERS, filters); requestMap.put(JsonKey.REQUEST, requestBody); String data = TestUtil.mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri(SEARCH_LOCATION_URL).method("POST"); //req.headers(headerMap); Result result = Helpers.route(application,req); assertEquals(200, result.status()); }
Example #9
Source File: BadgeAssertionControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test @Ignore public void getAssertionListTest() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); List<String> assertionList = new ArrayList<String>(); assertionList.add("assertionId"); innerMap.put(JsonKey.FILTERS, assertionList); Map<String, Object> dataMap = new HashMap<>(); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/issuer/badge/assertion/search").method("POST"); Result result = Helpers.route(application, req); assertEquals(200, result.status()); }
Example #10
Source File: BadgeAssertionControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void getAssertionListWithInvalidTYpe() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(BadgingJsonKey.ASSERTION_ID, "assertionId"); List<Map<String, Object>> list = new ArrayList<>(); list.add(innerMap); Map<String, Object> dataMap = new HashMap<>(); dataMap.put(BadgingJsonKey.BADGE_ASSERTIONS, list); requestMap.put(JsonKey.REQUEST, dataMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/issuer/badge/assertion/search").method("POST"); Result result = Helpers.route(application, req); assertEquals(400, result.status()); }
Example #11
Source File: OrganisationControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
public String getResponseCode(Result result) { String responseStr = Helpers.contentAsString(result); ObjectMapper mapper = new ObjectMapper(); try { Response response = mapper.readValue(responseStr, Response.class); if (response != null) { ResponseParams params = response.getParams(); return params.getStatus(); } } catch (Exception e) { ProjectLogger.log( "BaseControllerTest:getResponseCode: Exception occurred with error message = " + e.getMessage(), LoggerEnum.ERROR.name()); } return ""; }
Example #12
Source File: UserControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
public String getResponseCode(Result result) { String responseStr = Helpers.contentAsString(result); ObjectMapper mapper = new ObjectMapper(); try { Response response = mapper.readValue(responseStr, Response.class); if (response != null) { ResponseParams params = response.getParams(); return params.getStatus(); } } catch (Exception e) { ProjectLogger.log( "BaseControllerTest:getResponseCode: Exception occurred with error message = " + e.getMessage(), LoggerEnum.ERROR.name()); } return ""; }
Example #13
Source File: ClientControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testregisterClient() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put("clientName", "ap"); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/client/register").method("POST"); Result result = Helpers.route(application, req); assertEquals(200, result.status()); }
Example #14
Source File: EmailServiceControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testsendMail() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(JsonKey.ORG_NAME, "org123"); innerMap.put(JsonKey.SUBJECT, "subject"); innerMap.put(JsonKey.BODY, "body"); List<String> recepeintsEmails = new ArrayList<>(); recepeintsEmails.add("abc"); List<String> receipeintUserIds = new ArrayList<>(); receipeintUserIds.add("user001"); innerMap.put("recipientEmails", recepeintsEmails); innerMap.put("recipientUserIds", receipeintUserIds); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/notification/email").method("POST"); //req.headers(headerMap); Result result = Helpers.route(application,req); assertEquals(200, result.status()); }
Example #15
Source File: TnCControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
public String getResponseCode(Result result) { String responseStr = Helpers.contentAsString(result); ObjectMapper mapper = new ObjectMapper(); try { Response response = mapper.readValue(responseStr, Response.class); if (response != null) { ResponseParams params = response.getParams(); return params.getStatus(); } } catch (Exception e) { ProjectLogger.log( "BaseControllerTest:getResponseCode: Exception occurred with error message = " + e.getMessage(), LoggerEnum.ERROR.name()); } return ""; }
Example #16
Source File: GeoLocationControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testdeleteGeoLocation() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(JsonKey.ROOT_ORG_ID, "org123"); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/location/delete/123").method("DELETE"); //req.headers(headerMap); Result result = Helpers.route(application,req); assertEquals(200, result.status()); }
Example #17
Source File: BulkUploadControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testUploadLocationWithProperData() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(JsonKey.DATA, "sampleStream".getBytes(Charset.defaultCharset())); innerMap.put(GeoLocationJsonKey.LOCATION_TYPE, "State"); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/bulk/location/upload").method("POST"); Result result = Helpers.route(application, req); assertEquals(200, result.status()); }
Example #18
Source File: BaseApplicationTest.java From sunbird-lms-service with MIT License | 6 votes |
public <T> void setup(Class<T> actorClass) { try { application = new GuiceApplicationBuilder() .in(new File("path/to/app")) .in(Mode.TEST) .disable(StartModule.class) .build(); Helpers.start(application); system = ActorSystem.create("system"); props = Props.create(actorClass); ActorRef subject = system.actorOf(props); BaseController.setActorRef(subject); AccessLogFilter filter = PowerMockito.mock(AccessLogFilter.class); PowerMockito.mockStatic(RequestInterceptor.class); PowerMockito.mockStatic(TelemetryWriter.class); PowerMockito.when(RequestInterceptor.verifyRequestData(Mockito.any())).thenReturn("userId"); PowerMockito.mockStatic(OnRequestHandler.class); PowerMockito.doReturn("12345678990").when(OnRequestHandler.class, "getCustodianOrgHashTagId"); } catch (Exception e) { e.printStackTrace(); } }
Example #19
Source File: BulkUploadControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testUploadUser() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(JsonKey.DATA, "sampleStream".getBytes(Charset.defaultCharset())); innerMap.put(JsonKey.ORGANISATION_ID, "org123"); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/user/upload").method("POST"); Result result = Helpers.route(application, req); assertEquals(200, result.status()); }
Example #20
Source File: LocationControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testUpdateLocationWithType() { Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> requestBody = new HashMap<>(); requestBody.put(GeoLocationJsonKey.LOCATION_TYPE, LOCATION_TYPE); requestBody.put(JsonKey.ID, LOCATION_ID); requestMap.put(JsonKey.REQUEST, requestBody); String data = TestUtil.mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri(UPDATE_LOCATION_URL).method("PATCH"); //req.headers(headerMap); Result result = Helpers.route(application,req); assertEquals(400, result.status()); }
Example #21
Source File: UserDataEncryptionControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
public String getResponseCode(Result result) { String responseStr = Helpers.contentAsString(result); ObjectMapper mapper = new ObjectMapper(); try { Response response = mapper.readValue(responseStr, Response.class); if (response != null) { ResponseParams params = response.getParams(); return params.getStatus(); } } catch (Exception e) { ProjectLogger.log( "BaseControllerTest:getResponseCode: Exception occurred with error message = " + e.getMessage(), LoggerEnum.ERROR.name()); } return ""; }
Example #22
Source File: GeoLocationControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testsendNotification() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(JsonKey.ROOT_ORG_ID, "org123"); innerMap.put(JsonKey.TO, "c93"); Map map = new HashMap(); map.put(JsonKey.FROM_EMAIL, "fromEmail"); innerMap.put(JsonKey.DATA, map); innerMap.put(JsonKey.TYPE, "fcm"); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/notification/send").method("POST"); //req.headers(headerMap); Result result = Helpers.route(application,req); assertEquals(200, result.status()); }
Example #23
Source File: SearchControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testcompositeSearch() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(JsonKey.ORG_NAME, "org123"); innerMap.put(JsonKey.OBJECT_TYPE, JsonKey.ORGANISATION); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/search/compositesearch").method("POST"); //req.headers(headerMap); Result result = Helpers.route(application,req); assertEquals(200, result.status()); }
Example #24
Source File: OtpControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
public String getResponseCode(Result result) { String responseStr = Helpers.contentAsString(result); ObjectMapper mapper = new ObjectMapper(); try { Response response = mapper.readValue(responseStr, Response.class); if (response != null) { ResponseParams params = response.getParams(); return params.getStatus(); } } catch (Exception e) { ProjectLogger.log( "BaseControllerTest:getResponseCode: Exception occurred with error message = " + e.getMessage(), LoggerEnum.ERROR.name()); } return ""; }
Example #25
Source File: TestUtil.java From sunbird-lms-service with MIT License | 6 votes |
public static String getResponseCode(Result result) { String responseStr = Helpers.contentAsString(result); ObjectMapper mapper = new ObjectMapper(); try { Response response = mapper.readValue(responseStr, Response.class); if (response != null) { ResponseParams params = response.getParams(); return params.getStatus(); } } catch (Exception e) { ProjectLogger.log( "BaseControllerTest:getResponseCode: Exception occurred with error message = " + e.getMessage(), LoggerEnum.ERROR.name()); } return ""; }
Example #26
Source File: LocationControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testCreateLocation() { when(RequestInterceptor.verifyRequestData(Mockito.anyObject())).thenReturn(USER_TOKEN); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> locationData = new HashMap<>(); locationData.put(JsonKey.NAME, LOCATION_NAME); locationData.put(JsonKey.CODE, LOCATION_CODE); locationData.put(GeoLocationJsonKey.LOCATION_TYPE, LOCATION_TYPE); requestMap.put(JsonKey.REQUEST, locationData); String data = TestUtil.mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri(CREATE_LOCATION_URL).method("POST"); //req.headers(headerMap); Result result = Helpers.route(application,req); assertEquals(200, result.status()); }
Example #27
Source File: NotesControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testSearchNoteSuccess() { Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); Map<String, Object> filterMap = new HashMap<>(); filterMap.put(JsonKey.ID, "123"); innerMap.put(JsonKey.FILTERS, filterMap); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/note/search").method("POST"); //req.headers(headerMap); Result result = Helpers.route(application,req); assertEquals(200, result.status()); }
Example #28
Source File: DbOperationControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testread() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(ENTITY_NAME, entityName); // innerMap.put(INDEXED , true); // innerMap.put(JsonKey.USER_ID , "usergt78y4ry8"); innerMap.put(JsonKey.ID, "ggudy8d8ydyy8ddy9"); /*Map<String , Object> payLoad = new HashMap<>(); payLoad.put(JsonKey.USER_ID , "usergt78y4ry8"); payLoad.put(JsonKey.ID , "ggudy8d8ydyy8ddy9"); innerMap.put(PAYLOAD , payLoad);*/ requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/object/read").method("POST"); /*//req.headers(headerMap);*/ Result result = Helpers.route(application,req); assertEquals(200, result.status()); }
Example #29
Source File: FileStorageControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testuploadFileService() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(JsonKey.DATA, "uploadFILEData".getBytes()); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/file/upload").method("POST"); //req.headers(headerMap); Result result = Helpers.route(application,req); assertEquals(200, result.status()); }
Example #30
Source File: DbOperationControllerTest.java From sunbird-lms-service with MIT License | 6 votes |
@Test public void testupdate() { PowerMockito.mockStatic(RequestInterceptor.class); when(RequestInterceptor.verifyRequestData(Mockito.anyObject())) .thenReturn("{userId} uuiuhcf784508 8y8c79-fhh"); Map<String, Object> requestMap = new HashMap<>(); Map<String, Object> innerMap = new HashMap<>(); innerMap.put(ENTITY_NAME, entityName); innerMap.put(INDEXED, true); Map<String, Object> payLoad = new HashMap<>(); payLoad.put(JsonKey.USER_ID, "usergt78y4ry85464"); payLoad.put(JsonKey.ID, "ggudy8d8ydyy8ddy9"); innerMap.put(PAYLOAD, payLoad); requestMap.put(JsonKey.REQUEST, innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/object/update").method("POST"); /*//req.headers(headerMap);*/ Result result = Helpers.route(application,req); assertEquals(200, result.status()); }