I am currently carrying out test automation using a Selenium based Automation framework. I am currently sending in HTTP requests in order to create an API suite.
However the next URL I need to post in is part of a text/event-stream. The data I require to extract is within the eventStream itself.
a["{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"VirgoSessionToken\":\"8C7A0FAA-EA27-473A-BCC3-E568ABDBD403\",\"Localization\":{\"LocaleString\":\"en_UK\",\"LanguageTag\":\"en-UK\",\"DecimalSeparator\":\".\",\"ZeroDigit\":\"0\",\"ThousandsSeparator\":\",\",\"CurrencySymbolLocation\":\"PREFIX\"},\"Balance\":{\"Timestamp\":1493730819967,\"Banks\":{\"CREDIT\":{\"Amount\":83872,\"CurrencyCode\":\"GBP\",\"MinorCurrencyUnits\":2,\"CurrencySymbol\":\"GBP\"},\"WINNINGS\":{\"Amount\":0,\"CurrencyCode\":\"GBP\",\"MinorCurrencyUnits\":2,\"CurrencySymbol\":\"GBP\"}}},\"Preferences\":{\"Global\":{},\"Game\":{}},\"State\":{\"value\":\"{\\\"serverState\\\":{\\\"player\\\":{\\\"uniqueVirgoId\\\":\\\"f85551d0-2f36-11e7-9136-314c3f96f318\\\",\\\"playerBindingState\\\":{\\\"20\\\":0,\\\"40\\\":0,\\\"60\\\":0,\\\"80\\\":0,\\\"100\\\":0,\\\"200\\\":0,\\\"400\\\":0,\\\"600\\\":0,\\\"800\\\":0,\\\"1000\\\":0,\\\"2000\\\":0,\\\"4000\\\":0,\\\"6000\\\":0,\\\"8000\\\":0,\\\"10000\\\":0},\\\"populated\\\":true},\\\"game\\\":{\\\"currencyCode\\\":\\\"\\\"}},\\\"jackpotState\\\":{}}\"},\"ApiPhase\":\"Idle\"}}"]
I need to extract the Amount value using Java. Apologies if the code formatting isn't great.
Is there a best way to extract Data from EventStreams?
As an example of what my framework does:
String webSocketUrl = insHostedUrl + responseTitle + "/xc_yx4r_" + "/eventsource";
assertTrue(httpCreateRequest("post", webSocketUrl);
assertTrue(httpSendRequest());
response = httpGetResponse();
This posts in the URL that is visible in the requests. However this does not get me to the eventStream data.