@Test public void testSerializeDeserializeSearch() { try { OdigeoRequestBuilder odigeoRequestBuilder = new OdigeoRequestBuilder(); Search search = odigeoRequestBuilder.buildRequest(); checkPreferences(search); String json = gson.toJson(search); Search search1 = gson.fromJson(json, Search.class); String json1 = gson.toJson(search1); System.out.println(json); assertEquals(json, json1); XMLGregorianCalendar date = search .getSearchRequest() .getItinerarySearchRequest() .getSegmentRequests() .get(0) .getDate(); XMLGregorianCalendar date1 = search1 .getSearchRequest() .getItinerarySearchRequest() .getSegmentRequests() .get(0) .getDate(); System.out.println(date); System.out.println(date1); assertEquals(date, date1); } catch (Exception e) { JunitConstants.reportError(e); } }
@Test public void testBuildRequestRequestParams() { try { RequestBuilderInterface<Search> odigeoRequestBuilder = new OdigeoRequestBuilder(); RequestParams params = TestConstants.oneMonthToGoRequestParamFromJson; Route route = params.getRouteAsList().get(0); Map<String, Search> searchList = odigeoRequestBuilder.buildRequest(params); Search search = searchList.get(route.getKey()); String json = gson.toJson(search); // System.out.println(json); Search search1 = gson.fromJson(json, Search.class); assertEquals( search .getSearchRequest() .getItinerarySearchRequest() .getSegmentRequests() .get(0) .getDate(), search1 .getSearchRequest() .getItinerarySearchRequest() .getSegmentRequests() .get(0) .getDate()); checkPreferences(search); } catch (Exception e) { JunitConstants.reportError(e); } }
@Test public void testBuildRequest() { try { OdigeoRequestBuilder odigeoRequestBuilder = new OdigeoRequestBuilder(); Search search = odigeoRequestBuilder.buildRequest(); checkPreferences(search); } catch (Exception e) { JunitConstants.reportError(e); } }
@Test public void testThomas1() { try { RequestParams requestParams = JsonUtilities.readFromInputStream(RequestParams.class, "/json/thomas1.json"); OdigeoRequestBuilder odigeoRequestBuilder = new OdigeoRequestBuilder(); Map<String, Search> search = odigeoRequestBuilder.buildRequest(requestParams); String builtString = JsonUtilities.getGson().toJson(search); String savedString = JsonUtilities.inputStreamToString("/json/thomas1Search.json"); assertEquals( savedString.replaceAll("46.31.194.10", ProchainvolUtilities.getMyIPAddress()), builtString); } catch (Exception e) { JunitConstants.reportError(e); } }