@Test public void sessionIMChatAccept13() throws JsonGenerationException, JsonMappingException, IOException { Setup.majorTest("Chat/IM", "isComposing functionality between users 3 and 4"); Setup.startTest("Send isComposing from User 3"); IsComposing isComposing = new IsComposing("active", new java.util.Date(), "text/plain", 60); ObjectMapper mapper = new ObjectMapper(); String jsonRequestData = "{\"isComposing\":" + mapper.writeValueAsString(isComposing) + "}"; System.out.println("Sending " + jsonRequestData); RestAssured.authentication = RestAssured.basic(Setup.TestUser3, Setup.applicationPassword); Response resp = RestAssured.given() .contentType("application/json") .body(jsonRequestData) .expect() .log() .ifError() .statusCode(204) .post(Setup.sendIMURL(Setup.TestUser3, Setup.TestUser4Contact, sessionID)); System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString()); Setup.endTest(); }
@Test public void adhocIMChat6() throws JsonGenerationException, JsonMappingException, IOException { Setup.startTest("Checking that User 1 has received a chat message"); receiveMessageStatusURL = INVALID; String url = (Setup.channelURL[1].split("username\\=")[0]) + "username="******"notificationList.messageNotification.chatMessage.text", Matchers.hasItem("how are you"), "notificationList.messageNotification.sessionId", Matchers.hasItem("adhoc"), "notificationList.messageNotification.messageId", Matchers.notNullValue(), "notificationList.messageNotification.senderAddress", Matchers.hasItem(Setup.TestUser2Contact), "notificationList.messageNotification.link", Matchers.notNullValue()) .post(url); System.out.println("Response = " + response.getStatusCode() + " / " + response.asString()); receiveMessageStatusURL = response.jsonPath().getString("notificationList.messageNotification[0].link[0].href"); System.out.println("message status URL = " + receiveMessageStatusURL); Setup.endTest(); }
private void subscribeToAddressBookNotifications(String userID, int i) { String test = "Subscribing User 1 to Address Book Notifications"; startTest(test); String clientCorrelator = Long.toString(System.currentTimeMillis()); String callback = callbackURL[i]; String requestData = requestDataClean(addressBookRequestData, clientCorrelator, callback); String url = replace(addressBookSubscriptionURL, apiVersion, userID); RestAssured.authentication = RestAssured.basic(userID, applicationPassword); Response response = RestAssured.given() .contentType("application/json") .body(requestData) .expect() .log() .ifError() .statusCode(201) .post(url); JsonPath jsonData = response.jsonPath(); subscriptionURL[i] = jsonData.getString("abChangesSubscription.resourceURL"); LOGGER.info("Response received = " + response.getStatusCode()); LOGGER.info("Body = " + response.asString()); endTest(test); }
@Test public void sessionIMChatAccept21() throws JsonGenerationException, JsonMappingException, IOException { Setup.startTest("Send invalid isComposing from User 4"); IsComposing isComposing = new IsComposing("rubbish", new java.util.Date(), "text/plain", 60); ObjectMapper mapper = new ObjectMapper(); String jsonRequestData = "{\"isComposing\":" + mapper.writeValueAsString(isComposing) + "}"; System.out.println("Sending " + jsonRequestData); RestAssured.authentication = RestAssured.basic(Setup.TestUser4, Setup.applicationPassword); Response resp = RestAssured.given() .contentType("application/json") .body(jsonRequestData) .expect() .log() .ifError() .statusCode(400) .post(Setup.sendIMURL(Setup.TestUser4, Setup.TestUser3Contact, receiveSessionID)); /* * 400 / {"requestError": {"serviceException": { * "messageId":"SVC002","variables": ["State is not valid. Received 'rubbish'"],"text":"Invalid input value for message. Part %0"}}} */ System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString()); Setup.endTest(); }
@Test public void adhocIMChat8() { Setup.startTest("Checking IM notifications for user 2"); RestAssured.authentication = RestAssured.basic(Setup.TestUser2, Setup.applicationPassword); String url = (Setup.channelURL[2].split("username\\=")[0]) + "username="******"notificationList.chatEventNotification.eventType", Matchers.hasItem("Accepted"), "notificationList.chatEventNotification.sessionId", Matchers.hasItem("adhoc") ).*/ post(url); System.out.println( "Response = " + notifications2.getStatusCode() + " / " + notifications2.asString()); Setup.endTest(); }
@Test public void sessionIMChatAccept10() { Setup.startTest("Checking the receiver status"); RestAssured.authentication = RestAssured.basic(Setup.TestUser4, Setup.applicationPassword); Response status = RestAssured.given() .expect() .log() .ifError() .statusCode(200) .body("messageStatusReport.status", Matchers.equalTo("DISPLAYED")) .get(Setup.prepareForTest(receiveMessageStatusURL)); System.out.println("Response = " + status.getStatusCode() + " / " + status.asString()); Setup.endTest(); }
@Test public void adhocIMChat2() { Setup.startTest("Checking the sender status"); RestAssured.authentication = RestAssured.basic(Setup.TestUser1, Setup.applicationPassword); Response status = RestAssured.given() .expect() .log() .ifError() .statusCode(200) .body("messageStatusReport.status", Matchers.is("DISPLAYED")) .get(sendMessageStatusURL); System.out.println("Response = " + status.getStatusCode() + " / " + status.asString()); Setup.endTest(); }
@Test public void sessionIMChatAccept22() throws JsonGenerationException, JsonMappingException, IOException { Setup.startTest("Close chat by User 4"); RestAssured.authentication = RestAssured.basic(Setup.TestUser4, Setup.applicationPassword); Response resp = RestAssured.given() .expect() .log() .ifError() .statusCode(204) .delete( Setup.chatSessionIMURL(Setup.TestUser4, Setup.TestUser3Contact, receiveSessionID)); System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString()); Setup.endTest(); }
@Test public void updateSubscriptionForUser1() { String userID = user1; int i = 1; startNotificationChannel(userID, i); subscribeToAddressBookNotifications(userID, i); String test = "Updating/Extending the Subscription to Address Book Notifications for User 1"; startTest(test); String clientCorrelator = Long.toString(System.currentTimeMillis()); String callback = callbackURL[i]; String requestData = requestDataClean(updateAddressBookRequestData, clientCorrelator, callback); String cleanUserID = cleanPrefix(userID); String url = subscriptionURL[i]; url = prepare(url); RestAssured.authentication = RestAssured.basic(userID, applicationPassword); Response response = RestAssured.given() .contentType("application/json") .body(requestData) .expect() .log() .ifError() .statusCode(200) .body( "abChangesSubscription.resourceURL", StringContains.containsString(cleanUserID), "abChangesSubscription.callbackReference.callbackData", IsEqual.equalTo("GSMA1"), "abChangesSubscription.callbackReference.notifyURL", IsEqual.equalTo(callbackURL[i]), "abChangesSubscription.callbackReference.notificationFormat", IsEqual.equalTo("JSON")) .put(url); LOGGER.info("Response Received = " + response.getStatusCode()); LOGGER.info("Body = " + response.asString()); endTest(test); }
@Test public void sessionIMChatAccept4() throws JsonGenerationException, JsonMappingException, IOException { Setup.startTest("Sending IM chat from User 3 to User 4"); ChatMessage chatMessage = new ChatMessage("hello user4", "Displayed"); ObjectMapper mapper = new ObjectMapper(); String jsonRequestData = "{\"chatMessage\":" + mapper.writeValueAsString(chatMessage) + "}"; System.out.println("Sending json=" + jsonRequestData); RestAssured.authentication = RestAssured.basic(Setup.TestUser3, Setup.applicationPassword); Response resp = RestAssured.given() .contentType("application/json") .body(jsonRequestData) .expect() .log() .ifError() .statusCode(201) .body( "resourceReference.resourceURL", StringContains.containsString( Setup.encodedValue(Setup.TestUser3) + "/oneToOne/" + Setup.encodedValue(Setup.TestUser4Contact) + "/" + sessionID + "/messages/")) .post(Setup.sendIMURL(Setup.TestUser3, Setup.TestUser4Contact, sessionID)); sendMessageStatusURL = resp.jsonPath().getString("resourceReference.resourceURL"); String[] parts = sendMessageStatusURL.split("/messages/"); sentMessageID = parts[1].replaceAll("/status", ""); System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString()); System.out.println("resourceURL = " + sendMessageStatusURL); System.out.println("sentMessageID = " + sentMessageID); try { Thread.sleep(1500); } catch (InterruptedException e) { } Setup.endTest(); }
@Test public void unsubscribeUnsubscribedUserFromAddressBookSubscriptions() { String userID = user3; TestUtils.startNotificationChannel( userThree, notificationChannelURL, apiVersion, validLongPoll, applicationUsername, applicationPassword); // subscribeToAddressBookNotifications(userID, i); String test = "Unsubscribe User 1 from Address Book Subscriptions"; startTest(test); String url = replace(addressBookSubscriptionURL, apiVersion, userID); url = url + "/" + userID; RestAssured.authentication = RestAssured.basic(userID, applicationPassword); Response response = RestAssured.given() .auth() .preemptive() .basic(applicationUsername, applicationPassword) .expect() .log() .ifError() .statusCode(403) .delete(url); LOGGER.info("Received Response: " + response.getStatusCode()); JsonPath jsonData = response.jsonPath(); String errorCode = jsonData.get("requestError.serviceException.messageId"); String errorMessage = jsonData.get("requestError.serviceException.variables[0]"); LOGGER.info("Error Code: " + errorCode); LOGGER.info("Error Message: " + errorMessage); endTest(test); }
@Test public void unsubscribeUser2FromAddressBookSubscriptions() { String userID = user2; TestUtils.startNotificationChannel( userTwo, notificationChannelURL, apiVersion, validLongPoll, applicationUsername, applicationPassword); TestUtils.subscribeToAddressBookNotifications( userTwo, addressBookSubscriptionURL, addressBookRequestData, apiVersion, applicationUsername, applicationPassword); String test = "Unsubscribe User 1 from Address Book Subscriptions"; startTest(test); String url = userTwo.getAddressSubscriptionUrl(); url = prepare(url); RestAssured.authentication = RestAssured.basic(userID, applicationPassword); Response response = RestAssured.given() .auth() .preemptive() .basic(applicationUsername, applicationPassword) .expect() .log() .ifError() .statusCode(204) .delete(url); LOGGER.info("Received Response: " + response.getStatusCode()); endTest(test); }
@Test public void sessionIMChatAccept2A() { Setup.startTest("Checking chat session status for User 3"); RestAssured.authentication = RestAssured.basic(Setup.TestUser3, Setup.applicationPassword); String url = Setup.chatSessionIMURL(Setup.TestUser3, Setup.TestUser4Contact, sessionID); System.out.println("URL = " + url); Response resp = RestAssured.given() .expect() .log() .ifError() .statusCode(201) .body( "chatSessionInformation.status", Matchers.equalTo("Connected"), "chatSessionInformation.tParticipantAddress", Matchers.equalTo(Setup.TestUser4Contact)) .get(url); System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString()); Setup.endTest(); }
@Test public void updateSubscriptionForUnsubscribedUser() { String userID = user3; int i = 3; startNotificationChannel(userID, i); // subscribeToAddressBookNotifications(userID, i); String test = "Updating/Extending the Subscription to Address Book Notifications for User 2"; startTest(test); String clientCorrelator = Long.toString(System.currentTimeMillis()); String callback = callbackURL[i]; String requestData = requestDataClean(updateAddressBookRequestData, clientCorrelator, callback); String url = replace(addressBookSubscriptionURL, apiVersion, userID); url = url + "/" + userID; RestAssured.authentication = RestAssured.basic(userID, applicationPassword); Response response = RestAssured.given() .contentType("application/json") .body(requestData) .expect() .log() .ifError() .statusCode(400) .put(url); LOGGER.info("Response Received = " + response.getStatusCode()); JsonPath jsonData = response.jsonPath(); String errorCode = jsonData.get("requestError.serviceException.messageId"); String errorMessage = jsonData.get("requestError.serviceException.variables[0]"); LOGGER.info("Error Code: " + errorCode); LOGGER.info("Error Message: " + errorMessage); endTest(test); }
@Test public void adhocIMChat() throws JsonGenerationException, JsonMappingException, IOException { Setup.majorTest("Chat/IM", "Adhoc chat between users 1 and 2"); restart(); Setup.startTest("Testing initiating IM chat between User 1 and User 2"); ChatMessage chatMessage = new ChatMessage("hello", "Displayed"); ObjectMapper mapper = new ObjectMapper(); String jsonRequestData = "{\"chatMessage\":" + mapper.writeValueAsString(chatMessage) + "}"; System.out.println("Sending json=" + jsonRequestData); RestAssured.authentication = RestAssured.basic(Setup.TestUser1, Setup.applicationPassword); Response resp = RestAssured.given() .contentType("application/json") .body(jsonRequestData) .expect() .log() .ifError() .statusCode(201) .body( "resourceReference.resourceURL", StringContains.containsString( Setup.encodedValue(Setup.TestUser1) + "/oneToOne/" + Setup.encodedValue(Setup.TestUser2Contact))) .post(Setup.sendIMURL(Setup.TestUser1, Setup.TestUser2Contact, "adhoc")); sendMessageStatusURL = resp.jsonPath().getString("resourceReference.resourceURL"); System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString()); System.out.println("resourceURL = " + sendMessageStatusURL); try { Thread.sleep(1500); } catch (InterruptedException e) { } Setup.endTest(); }
@Test public void sessionIMChatAccept1B() { Setup.startTest("Sending accept chat for user 4"); RestAssured.authentication = RestAssured.basic(Setup.TestUser4, Setup.applicationPassword); Response resp = RestAssured.given() .expect() .log() .ifError() .statusCode(204) .put( Setup.chatSessionIMStatusURL( Setup.TestUser4, Setup.TestUser3Contact, receiveSessionID)); System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString()); try { Thread.sleep(2500); } catch (InterruptedException e) { } Setup.endTest(); }
public void startNotificationChannel(String userID, int i) { String test = "Starting the Notification Channel"; startTest(test); String url = replace(notificationChannelURL, apiVersion, userID); RestAssured.authentication = RestAssured.basic(userID, applicationPassword); // Make HTTP POST Request... Response response = RestAssured.given().body(validLongPoll).expect().log().ifError().statusCode(201).post(url); JsonPath jsonData = response.jsonPath(); resourceURL[i] = jsonData.get("notificationChannel.resourceURL"); channelURL[i] = jsonData.get("notificationChannel.channelData.channelURL"); callbackURL[i] = jsonData.get("notificationChannel.callbackURL"); LOGGER.info("" + response.getStatusCode()); LOGGER.info("Resource URL: " + resourceURL[i]); LOGGER.info("Channel URL: " + channelURL[i]); LOGGER.info("Callback URL: " + callbackURL[i]); endTest(test); }
@Test public void sessionIMChatAccept() throws JsonGenerationException, JsonMappingException, IOException { Setup.majorTest("Chat/IM", "Confirmed chat between users 3 and 4"); restart(); Setup.startTest("Testing initiating IM chat session between User 3 and User 4"); String requestData3 = "{\"chatNotificationSubscription\":{ \"callbackReference\":{\"notifyURL\":\"" + Setup.callbackURL[3] + "\",\"callbackData\":\"GSMA3\"},\"clientCorrelator\":\"" + UUID.randomUUID().toString() + "\", \"duration\":900, \"confirmedChatSupported\":true, \"adhocChatSupported\":false}}"; String requestData4 = "{\"chatNotificationSubscription\":{ \"callbackReference\":{\"notifyURL\":\"" + Setup.callbackURL[4] + "\",\"callbackData\":\"GSMA3\"},\"clientCorrelator\":\"" + UUID.randomUUID().toString() + "\", \"duration\":900, \"confirmedChatSupported\":true, \"adhocChatSupported\":false}}"; System.out.println("Setting chat subscription for confirmed session for user 3"); RestAssured.authentication = RestAssured.basic(Setup.TestUser3, Setup.applicationPassword); Response resp = RestAssured.given() .contentType("application/json") .body(requestData3) .expect() .log() .ifError() .statusCode(201) .post(Setup.chatSubscriptionURL(Setup.TestUser3)); System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString()); System.out.println("Setting chat subscription for confirmed session for user 4"); RestAssured.authentication = RestAssured.basic(Setup.TestUser4, Setup.applicationPassword); resp = RestAssured.given() .contentType("application/json") .body(requestData4) .expect() .log() .ifError() .statusCode(201) .post(Setup.chatSubscriptionURL(Setup.TestUser4)); System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString()); ChatSessionInformation chatSessionInformation = new ChatSessionInformation( "Session based IM", Setup.TestUser3Contact, "MO", Setup.TestUser4Contact, "MT"); ObjectMapper mapper = new ObjectMapper(); String jsonRequestData = "{\"chatSessionInformation\":" + mapper.writeValueAsString(chatSessionInformation) + "}"; System.out.println("Sending json=" + jsonRequestData); RestAssured.authentication = RestAssured.basic(Setup.TestUser3, Setup.applicationPassword); resp = RestAssured.given() .contentType("application/json") .body(jsonRequestData) .expect() .log() .ifError() .statusCode(201) .body( "chatSessionInformation.status", Matchers.equalTo("Invited"), "chatSessionInformation.originatorAddress", Matchers.equalTo(Setup.TestUser3Contact), "chatSessionInformation.tParticipantAddress", Matchers.equalTo(Setup.TestUser4Contact), "chatSessionInformation.resourceURL", StringContains.containsString( Setup.encodedValue(Setup.TestUser3) + "/oneToOne/" + Setup.encodedValue(Setup.TestUser4Contact))) .post(Setup.createIMChatSessionURL(Setup.TestUser3, Setup.TestUser4Contact)); System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString()); JsonPath jsonData = resp.jsonPath(); sendSessionURL = jsonData.getString("chatSessionInformation.resourceURL"); System.out.println("sendSessionURL = " + sendSessionURL); try { Thread.sleep(500); } catch (InterruptedException e) { } Setup.endTest(); }