@Test public void testCreateOrg() { 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"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/create").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testCreateOrgInvalidRequestData() { 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 , null); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/create").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(400, result.status()); }
@Test public void testApproveOrg() { 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.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/org/approve").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testApproveOrgInvalidRequestData() { 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.ORGANISATION_ID , null); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/approve").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(400, result.status()); }
@Test public void testUpdateOrg() { 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.ORGANISATION_ID , "org123"); innerMap.put(JsonKey.ROOT_ORG_ID , "rootorg12"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/update").method("PATCH"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testupdateOrgStatus() { 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.ORGANISATION_ID , "org123"); innerMap.put(JsonKey.STATUS, new BigInteger("1")); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/status/update").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(404, result.status()); }
@Test public void testgetOrgDetails() { 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.ORGANISATION_ID , "org123"); innerMap.put(JsonKey.STATUS, new BigInteger("1")); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/read").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testaddMemberToOrganisation() { 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.ORGANISATION_ID , "org123"); innerMap.put(JsonKey.STATUS, new BigInteger("1")); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/member/add").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testremoveMemberFromOrganisation() { 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.ORGANISATION_ID , "org123"); innerMap.put(JsonKey.STATUS, new BigInteger("1")); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/member/remove").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testjoinUserOrganisation() { 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.ORGANISATION_ID , "org123"); innerMap.put(JsonKey.STATUS, new BigInteger("1")); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/member/join").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testapproveUserOrganisation() { 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.ORGANISATION_ID , "org123"); innerMap.put(JsonKey.STATUS, new BigInteger("1")); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/member/approve").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testrejectUserOrganisation() { 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.ORGANISATION_ID , "org123"); innerMap.put(JsonKey.STATUS, new BigInteger("1")); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/member/approve").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testdownloadOrgs() { 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.ORGANISATION_ID , "org123"); innerMap.put(JsonKey.STATUS, new BigInteger("1")); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/download").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testsearchOrgs() { 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.ORGANISATION_ID , "org123"); innerMap.put(JsonKey.STATUS, new BigInteger("1")); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/search").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testcreateOrgType() { 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.NAME , "org123"); innerMap.put(JsonKey.STATUS, new BigInteger("1")); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/type/create").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testupdateOrgType() { 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.NAME , "org123"); innerMap.put(JsonKey.ID, "1"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/org/type/update").method("PATCH"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@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"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testupdateClientKey() { 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("x-authenticated-client-token" , "ap"); innerMap.put("x-authenticated-client-id","123"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/client/key/update").method("PATCH"); headerMap.put("x-authenticated-client-token" , new String[]{"ap"}); headerMap.put("x-authenticated-client-id",new String[]{"123"}); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testCreateNote() { 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 , "uuiuhcf784508 8y8c79-fhh"); innerMap.put(JsonKey.COURSE_ID , "crs123"); innerMap.put(JsonKey.CONTENT_ID , "content123"); innerMap.put(JsonKey.NOTE , "note"); innerMap.put(JsonKey.TITLE , "learn"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/note/create").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testCreateNoteWithInvalidRequestData() { 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 , ""); innerMap.put(JsonKey.COURSE_ID , "org123"); innerMap.put(JsonKey.NOTE , ""); innerMap.put(JsonKey.TITLE , "org123"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/note/create").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(400, result.status()); }
@Test public void testUpdateNote() { 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.ID , "123"); innerMap.put(JsonKey.TAGS , "123"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/note/update/123").method("PATCH"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testDeleteNote() { 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.ID , "123"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/note/delete/123").method("DELETE"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testsearchNote() { 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<>(); 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 = route(req); assertEquals(200, result.status()); }
public void testCreate() { 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 , "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/create").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); try { Thread.sleep(4000); } catch (InterruptedException e) { e.printStackTrace(); } }
public void testCreateWithWrongEntityName() { 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+"-wrong"); innerMap.put(INDEXED , true); 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/create").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(400, result.status()); }
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 = route(req); assertEquals(200, result.status()); }
public void testdelete() { 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.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/delete").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
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 = route(req); assertEquals(200, result.status()); }
public void testreadAll() { 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 , "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/list").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
public void testsearch() { 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); List<String> requiredFields = new ArrayList<>(); requiredFields.add("userid"); innerMap.put(REQUIRED_FIELDS , requiredFields); Map<String, Object> filters = new HashMap<>(); filters.put(JsonKey.USER_ID ,"usergt78y4ry85464" ); innerMap.put(JsonKey.FILTERS , filters); innerMap.put(JsonKey.ID , "ggudy8d8ydyy8ddy9"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/object/search").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
public void testgetMetrics() { 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); List<String> requiredFields = new ArrayList<>(); requiredFields.add("userid"); innerMap.put(REQUIRED_FIELDS , requiredFields); Map<String, Object> filters = new HashMap<>(); filters.put(JsonKey.USER_ID ,"usergt78y4ry85464" ); innerMap.put(JsonKey.FILTERS , filters); innerMap.put(JsonKey.ID , "ggudy8d8ydyy8ddy9"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/object/metrics").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@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 = route(req); assertEquals(200, result.status()); }
@Test public void testsync() { 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.OBJECT_TYPE, JsonKey.ORGANISATION); innerMap.put(JsonKey.OPERATION_FOR , "learner"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/data/sync").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testlogin() { 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.USERNAME , "userName"); innerMap.put(JsonKey.PASSWORD , "john"); innerMap.put(JsonKey.SOURCE , "src"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/user/login").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testlogout() { 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.USERNAME , "userName"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/user/logout").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@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 = route(req); assertEquals(200, result.status()); }
@Test public void testsaveAssessment() { 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("courseId" , "course-123"); innerMap.put("contentId" , "content01"); innerMap.put("attemptId" , "2"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/assessment/update").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testupdateContentState() { 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 list = new ArrayList(); Map map = new HashMap(); map.put(JsonKey.CONTENT_ID ,"6778"); map.put(JsonKey.STATUS , "Active"); list.add(map); innerMap.put("contents" , list); innerMap.put("courseId" , "course-123"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/content/state/update").method("PATCH"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testassignRoles() { 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 , "user123"); List<String> roles = new ArrayList<>(); roles.add("user"); innerMap.put(JsonKey.ROLES , roles); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/user/assign/role").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }
@Test public void testforgotpassword() { 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.USERNAME , "user01"); requestMap.put(JsonKey.REQUEST , innerMap); String data = mapToJson(requestMap); JsonNode json = Json.parse(data); RequestBuilder req = new RequestBuilder().bodyJson(json).uri("/v1/user/forgotpassword").method("POST"); req.headers(headerMap); Result result = route(req); assertEquals(200, result.status()); }