From b1c5c3ccf56b1eefaff78c4aede32e55b1c4ae5e Mon Sep 17 00:00:00 2001 From: Jean-Michel Glorian Date: Wed, 25 May 2022 22:32:02 +0200 Subject: [PATCH] remove test to request the registry with keywords --- src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java | 19 ------------------- src/main/java/eu/omp/irap/vespa/epntapclient/epntap/EpnTapInterface.java | 32 -------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java | 65 ++--------------------------------------------------------------- src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java | 93 --------------------------------------------------------------------------------------------- 4 files changed, 2 insertions(+), 207 deletions(-) diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java index fbc30e6..6468b66 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java @@ -94,26 +94,7 @@ public class EpnTapConnection implements EpnTapInterface { return ServiceCtrl.getVoTable(query); } - @Override - public Resource getEPNVOresource(String ivoid) throws VOResourceException { - return VOResourceCtrl.getVOresource(ivoid); - } - - @Override - public List getEPNVOResources() throws VOResourceException { - List ivoids = VOResourceCtrl.getIvoidResources(ServiceCore.EPNCORE); - return VOResourceCtrl.getVOResources(ivoids); - } - // *** Getters *** - - @Override - public List getEPNVOResources(List keywords) - throws VOResourceException { - List ivoids = VOResourceCtrl.getVOResources(ServiceCore.EPNCORE, keywords); - return VOResourceCtrl.getVOResources(ivoids); - } - @Override public String getTAPURL(String ivoid) throws VOTableException { return (String) ServiceCtrl.getParameter(ivoid, "access_url"); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/EpnTapInterface.java b/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/EpnTapInterface.java index 270abd5..a000ea6 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/EpnTapInterface.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/EpnTapInterface.java @@ -103,38 +103,6 @@ public interface EpnTapInterface { VOTABLE getEPNServices(List keywords, List attributes) throws VOTableException; - /** - * Returns the VOResource element of the service identified by the ivoID. - * - * @param ivoid the ivoid of the service. - * @return The Resource of a service corresponding to the ivoid - * @throws VOResourceException Can not get the VOResource. - */ - Resource getEPNVOresource(String ivoid) throws VOResourceException; - - /** - * Returns a set of VOResource elements (one per EPN-TAP service). - * - * @return A list containing the VOResources of all EpnTap services. - * @throws VOResourceException Can not get the VOResource. - */ - List getEPNVOResources() throws VOResourceException; - - // *** Getters *** - - /** - * Returns a set of VOREsource elements (one per EPN-TAP service corresponding to the keywords). - * The way keywords are defined is still to be defined. - * - * @param keywords A list of keywords, which are the content of the *subject* JSON node in the - * query. - * @see - * this example request - * @return A list containing the selected VOResources. - * @throws VOResourceException Can not get the VOResource. - */ - List getEPNVOResources(List keywords) throws VOResourceException; /** * Returns the Access URL of an EPN-TAP Service. diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java index c1f1fb1..24bcbf5 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java @@ -52,9 +52,6 @@ public class VOResourceCtrl { /** The URL used to get the resources in JSON format. */ private static final String GET_JSONRESOURCES_URL = "http://voparis-registry.obspm.fr/vo/ivoa/1/voresources/search"; - /** The URL used to get the resources in VOResource (XML) format. */ - private static final String GET_VORESOURCE_URL = "http://voparis-registry.obspm.fr/vo/ivoa/1/voresources.xml"; - /** The logger for the class VOResourceController. */ private static final Logger LOGGER = Logger.getLogger(VOResourceCtrl.class.getName()); @@ -95,71 +92,13 @@ public class VOResourceCtrl { try { ivoidResources = parseIvoidResources(JsonUtils.readJsonFromNetwork(query)); } catch (CantSendQueryException e) { - throw new CantGetVOResourceException(GET_VORESOURCE_URL, e); + throw new CantGetVOResourceException(query, e); } LOGGER.info("Got resources: " + StringJoiner.join(ivoidResources)); return ivoidResources; } /** - * Get a resource from its identifier. - * - * @param identifier The resource identifier. - * @return The returned resource. - * @throws VOResourceException Can not get the VOResource. - */ - public static Resource getVOresource(String identifier) throws VOResourceException { - Map parameters = new HashMap<>(); - parameters.put("identifier", identifier); - String voResourcePath; - - try { - LOGGER.fine("Trying to get VOResource '" + identifier + "'..."); - String query = Network.buildGetRequest(GET_VORESOURCE_URL, parameters); - voResourcePath = Network.saveQuery(query); - } catch (CantSendQueryException e) { - throw new CantGetVOResourceException(GET_VORESOURCE_URL, e); - } - LOGGER.fine("VOResource downloaded in " + voResourcePath); - - try { - changeNamespaces(voResourcePath); - } catch (IOException e) { - throw new CantReadVOResourceException("The VOResource file can not be modified.", e); - } - - Resource voResource; - try { - File inputStream = new File(voResourcePath); - - Source source = new StreamSource(inputStream); - JAXBContext jc = JAXBContext.newInstance(Resource.class); - Unmarshaller unmarshaller = jc.createUnmarshaller(); - voResource = unmarshaller.unmarshal(source, Resource.class).getValue(); - - } catch (JAXBException e) { - throw new VOResourceIsNotValidException(voResourcePath, e); - } - return voResource; - } - - /** - * Get a list of Resources from a list of ivoid. - * - * @param ivoidResources A list of ivoIds - * @return A list of Resources corresponding to the ivoIDs. - * @throws VOResourceException Can not get the VOResource. - */ - public static List getVOResources(List ivoidResources) - throws VOResourceException { - List resources = new ArrayList<>(); - for (String ivoid : ivoidResources) { - resources.add(getVOresource(ivoid)); - } - return resources; - } - - /** * Get the list of ivoIDs of all resources which implements the specified core and match with * the keywords. * @@ -182,7 +121,7 @@ public class VOResourceCtrl { try { ivoidResources = parseIvoidResources(JsonUtils.readJsonFromNetwork(query)); } catch (CantSendQueryException e) { - throw new CantGetVOResourceException(GET_VORESOURCE_URL, e); + throw new CantGetVOResourceException(query, e); } LOGGER.info("Got resources: " + StringJoiner.join(ivoidResources)); return ivoidResources; diff --git a/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java b/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java index 004d9ef..c33eed7 100644 --- a/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java +++ b/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java @@ -233,99 +233,6 @@ public class EpnTapConnectionTest { assertEquals(AMDA_SHORT_NAME, data.getCell(0, "short_name")); } - /** - * Unit test for the class {@link EpnTapConnection#getEPNVOResources()}. - * - * @throws VOResourceException Can not get the VOresource. - */ - @Test - public void getEPNVOResourcesTest() throws VOResourceException { - LOGGER.info("getEPNVOResourcesTest"); - EpnTapConnection facade = new EpnTapConnection(); - - List resources = facade.getEPNVOResources(); - - int nbResources = resources.size(); - assertTrue(nbResources + " < 10", nbResources >= 10); - - Resource amda = null; - Resource apis = null; - for (Resource resource : resources) { - if (AMDA_IVOID.equals(resource.getIdentifier())) { - amda = resource; - } - if (APIS_IVOID.equals(resource.getIdentifier())) { - apis = resource; - } - } - assertNotNull("AMDA resource should be present.", amda); - assertNotNull("APIS resource should be present.", apis); - assertEquals(AMDA_SHORT_NAME, amda.getShortName()); - assertEquals(APIS_SHORT_NAME, apis.getShortName()); - } - - /** - * Unit test for the class {@link EpnTapConnection#getEPNVOResources(List)}. - * - * @throws VOResourceException Can not get the VOresource. - */ - @Test - public void getEPNVOResourcesWithKeywordsTest() throws VOResourceException { - LOGGER.info("getEPNVOResourcesWithKeywordsTest"); - EpnTapConnection facade = new EpnTapConnection(); - - final List keywords = new ArrayList<>(); - keywords.add("Virtual Observatory"); - keywords.add("Plasma Physics"); - keywords.add("Planetary Systems"); - List resources = facade.getEPNVOResources(keywords); - - assertEquals(resources.size(), 1); - - Resource amda = null; - for (Resource resource : resources) { - if (AMDA_IVOID.equals(resource.getIdentifier())) { - amda = resource; - } - } - assertNotNull("AMDA resource should be present.", amda); - } - - // *** Getters *** - - /** - * Unit test for the class {@link EpnTapConnection#getTAPURL(String)}. - * - * @throws VOTableException Can not get the VOTable corresponding to the service. - */ - @Test - public void getTAPURLTest() throws VOTableException { - LOGGER.info("getTAPURLTest"); - EpnTapConnection facade = new EpnTapConnection(); - - String tapURL = facade.getTAPURL(AMDA_IVOID); - - assertEquals(AMDA_ACCESS_URL, tapURL); - } - - /** - * Unit test for the class {@link EpnTapConnection#getEPNVOresource(String)}. - * - * @throws VOResourceException Can not get the VOresource. - */ - @Test - public void getVOResourceTest() throws VOResourceException { - LOGGER.info("getVOResourceTest"); - EpnTapConnection facade = new EpnTapConnection(); - - Resource resource = facade.getEPNVOresource(AMDA_IVOID); - - assertEquals("AMDA", resource.getShortName()); - assertEquals("Planetary and heliophysics plasma data at CDPP/AMDA", resource.getTitle()); - assertEquals("M. Gangloff", - resource.getCuration().getCreator().get(0).getName().getValue()); - } - // *** Queries *** /** -- libgit2 0.21.2