@Test public void testGetUri() throws Exception { StringBuilder queryString = buildBaseQueryString(); queryString.append("&itineraryId=1234&[email protected]"); final URI uri = itineraryRequest.getUri(); assertEquals("http", uri.getScheme()); assertEquals("api.ean.com", uri.getHost()); assertEquals("/ean-services/rs/hotel/v3/itin", uri.getPath()); assertEquals(queryString.toString(), uri.getQuery()); }
@Test public void testConsume() throws Exception { Itinerary itinerary = itineraryRequest.consume(JSONFileUtil.loadJsonFromFile("valid-itinerary.json")); assertNotNull(itinerary); assertEquals(107730857L, itinerary.id); assertEquals(CommonParameters.cid, String.valueOf(itinerary.affiliateId)); assertEquals(DateModifier.getDateFromString("01/28/2013"), itinerary.creationDate); assertEquals(DateModifier.getDateFromString("02/07/2013"), itinerary.itineraryStartDate); assertEquals(DateModifier.getDateFromString("02/10/2013"), itinerary.itineraryEndDate); doCustomerAssertions(itinerary.customer); doHotelConfirmationAssertions(itinerary.hotelConfirmations); }
@Test(expected = EanWsError.class) public void testConsumeEanWsError() throws Exception { itineraryRequest.consume(JSONFileUtil.loadJsonFromFile("error-itinerary.json")); }
@Test(expected = JSONException.class) public void testConsumeInvalidJson() throws Exception { itineraryRequest.consume(JSONFileUtil.loadJsonFromFile("invalid-itinerary.json")); }
@Test(expected = JSONException.class) public void testConsumeEmptyJson() throws Exception { itineraryRequest.consume(new JSONObject()); }
@Test public void testConsumeNullJson() throws Exception { assertNull(itineraryRequest.consume(null)); }
@Test public void testIsSecure() { assertThat(itineraryRequest.requiresSecure(), is(false)); }