@Test public void getBriefRecordsByBBOX_allIntersect() throws SAXException, IOException, FactoryException, TransformException { Client client = mock(Client.class); when(suite.getAttribute(SuiteAttribute.CLIENT.getName())).thenReturn(client); ClientResponse rsp = mock(ClientResponse.class); when(client.handle(any(ClientRequest.class))).thenReturn(rsp); when(rsp.getStatus()).thenReturn(ClientResponse.Status.OK.getStatusCode()); Document rspEntity = docBuilder.parse(this.getClass().getResourceAsStream("/rsp/GetRecordsResponse-full.xml")); BasicSearchTests spy = Mockito.spy(new BasicSearchTests()); Mockito.doReturn(rspEntity) .when(spy) .getResponseEntityAsDocument(any(ClientResponse.class), anyString()); spy.initCommonFixture(testContext); // BOX2D(32.5 -117.6, 34 -115) with CRS EPSG:4326 spy.setExtent(buildEnvelope(1)); spy.setGetEndpoint(URI.create("http://localhost/csw/v3")); spy.getBriefRecordsByBBOX(); }
@Test public void getBriefRecordsByBBOX_noneIntersect() throws SAXException, IOException, FactoryException, TransformException { thrown.expect(AssertionError.class); thrown.expectMessage("The envelopes do not intersect"); Client client = mock(Client.class); when(suite.getAttribute(SuiteAttribute.CLIENT.getName())).thenReturn(client); ClientResponse rsp = mock(ClientResponse.class); when(client.handle(any(ClientRequest.class))).thenReturn(rsp); when(rsp.getStatus()).thenReturn(ClientResponse.Status.OK.getStatusCode()); Document rspEntity = docBuilder.parse(this.getClass().getResourceAsStream("/rsp/GetRecordsResponse-full.xml")); BasicSearchTests spy = Mockito.spy(new BasicSearchTests()); Mockito.doReturn(rspEntity) .when(spy) .getResponseEntityAsDocument(any(ClientResponse.class), anyString()); spy.initCommonFixture(testContext); // BOX2D(472944 5363287, 516011 5456383) with CRS EPSG:32610 spy.setExtent(buildEnvelope(2)); spy.setGetEndpoint(URI.create("http://localhost/csw/v3")); spy.getBriefRecordsByBBOX(); }