Commit 628ba59c authored by Piotr Gawron's avatar Piotr Gawron
Browse files

fix on chebi connector (new version is used that uses https instead of http)

parent 30641f7c
package lcsb.mapviewer.annotation.services.annotators;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
......@@ -7,6 +9,7 @@ import java.util.List;
import java.util.Queue;
import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceException;
import org.apache.log4j.Logger;
......@@ -160,7 +163,8 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
try {
ChebiWebServiceClient client = getClient();
LiteEntityList entities = client.getLiteEntity(name, SearchCategory.CHEBI_NAME, MAX_SEARCH_RESULTS_FROM_CHEBI_API, StarsCategory.ALL);
LiteEntityList entities = client.getLiteEntity(name, SearchCategory.CHEBI_NAME, MAX_SEARCH_RESULTS_FROM_CHEBI_API,
StarsCategory.ALL);
List<LiteEntity> resultList = entities.getListElement();
for (LiteEntity liteEntity : resultList) {
......@@ -357,7 +361,8 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
try {
ChebiWebServiceClient client = getClient();
LiteEntityList entities = client.getLiteEntity(id, SearchCategory.CHEBI_ID, MAX_SEARCH_RESULTS_FROM_CHEBI_API, StarsCategory.ALL);
LiteEntityList entities = client.getLiteEntity(id, SearchCategory.CHEBI_ID, MAX_SEARCH_RESULTS_FROM_CHEBI_API,
StarsCategory.ALL);
List<LiteEntity> resultList = entities.getListElement();
for (LiteEntity liteEntity : resultList) {
......@@ -423,7 +428,7 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService
*
* @return {@link #client}
* @throws ChebiSearchException
* thrown when there is a problemw ith accessing information from
* thrown when there is a problem with accessing information from
* external chebi database
*/
private ChebiWebServiceClient getClient() throws ChebiSearchException {
......
......@@ -115,8 +115,8 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions {
Entity entity = new Entity();
entity.getOntologyChildren().add(item);
entity.getOntologyParents().add(item);
when(chebiWebServiceClient.getLiteEntity(any(), any(), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
.thenThrow(new ChebiWebServiceFault_Exception(null, null));
when(chebiWebServiceClient.getLiteEntity(any(), any(), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API),
any())).thenThrow(new ChebiWebServiceFault_Exception(null, null));
// we will use mock object as a connection to chebi server
backend.setClient(chebiWebServiceClient);
......@@ -270,7 +270,8 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions {
res = backend.getOntologyChebiIdsForChebiName("h2o");
assertNotNull(res);
assertTrue(res.size() > 1);
assertTrue(res.contains(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, "CHEBI:24431")));
assertTrue(
res.contains(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, "CHEBI:24431")));
} catch (Exception e) {
e.printStackTrace();
throw e;
......@@ -348,7 +349,8 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions {
Entity entity = new Entity();
entity.getOntologyChildren().add(item);
entity.getOntologyParents().add(item);
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME),
eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
.thenThrow(new ChebiWebServiceFault_Exception(null, null));
// we will use mock object as a connection to chebi server
......@@ -389,7 +391,8 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions {
public void testUpdateChemicalFromDb() throws Exception {
try {
SimpleMolecule simpleMolecule = new SimpleMolecule("id");
simpleMolecule.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, "CHEBI:15377"));
simpleMolecule
.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, "CHEBI:15377"));
backend.annotateElement(simpleMolecule);
......@@ -415,7 +418,8 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions {
simpleMolecule.setInChIKey("x");
simpleMolecule.setSmiles("x");
simpleMolecule.addSynonym("x");
simpleMolecule.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, "CHEBI:15377"));
simpleMolecule
.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, "CHEBI:15377"));
backend.annotateElement(simpleMolecule);
......@@ -502,8 +506,8 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions {
LiteEntity liteEntity = new LiteEntity();
liteEntityList.getListElement().add(liteEntity);
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
.thenReturn(liteEntityList);
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME),
eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any())).thenReturn(liteEntityList);
// we will use mock object as a connection to chebi server
backend.setClient(chebiWebServiceClient);
......@@ -551,11 +555,11 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions {
LiteEntity liteEntity = new LiteEntity();
liteEntityList.getListElement().add(liteEntity);
// when searching by name return empty list
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
.thenReturn(new LiteEntityList());
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME),
eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any())).thenReturn(new LiteEntityList());
// when searchng by all return list with elements
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.ALL), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
.thenReturn(liteEntityList);
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.ALL),
eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any())).thenReturn(liteEntityList);
// we will use mock object as a connection to chebi server
backend.setClient(chebiWebServiceClient);
......@@ -602,8 +606,8 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions {
LiteEntity liteEntity = new LiteEntity();
liteEntityList.getListElement().add(liteEntity);
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
.thenReturn(liteEntityList);
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME),
eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any())).thenReturn(liteEntityList);
// we will use mock object as a connection to chebi server
backend.setClient(chebiWebServiceClient);
......@@ -651,11 +655,11 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions {
LiteEntity liteEntity = new LiteEntity();
liteEntityList.getListElement().add(liteEntity);
// when searching by name return empty list
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
.thenReturn(new LiteEntityList());
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME),
eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any())).thenReturn(new LiteEntityList());
// when searchng by all return list with elements
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.ALL), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
.thenReturn(liteEntityList);
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.ALL),
eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any())).thenReturn(liteEntityList);
// we will use mock object as a connection to chebi server
backend.setClient(chebiWebServiceClient);
......@@ -685,7 +689,8 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions {
ChebiWebServiceClient chebiWebServiceClient = Mockito.mock(ChebiWebServiceClient.class);
// when searching by name return empty list
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME),
eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
.thenThrow(new ChebiWebServiceFault_Exception(null, null));
// we will use mock object as a connection to chebi server
......@@ -723,7 +728,8 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions {
Entity entity = new Entity();
entity.getOntologyChildren().add(item);
entity.getOntologyParents().add(item);
when(chebiWebServiceClient.getCompleteEntity(any(String.class))).thenThrow(new ChebiWebServiceFault_Exception(null, null));
when(chebiWebServiceClient.getCompleteEntity(any(String.class)))
.thenThrow(new ChebiWebServiceFault_Exception(null, null));
// we will use mock object as a connection to chebi server
backend.setClient(chebiWebServiceClient);
......@@ -787,8 +793,8 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions {
backend.setCache(null);
try {
ChebiWebServiceClient chebiWebServiceClient = Mockito.mock(ChebiWebServiceClient.class);
when(chebiWebServiceClient.getLiteEntity(any(), any(), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
.thenThrow(new ChebiWebServiceFault_Exception(null, null));
when(chebiWebServiceClient.getLiteEntity(any(), any(), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API),
any())).thenThrow(new ChebiWebServiceFault_Exception(null, null));
backend.setClient(chebiWebServiceClient);
assertEquals(ExternalServiceStatusType.DOWN, backend.getServiceStatus().getStatus());
} catch (Exception e) {
......@@ -828,10 +834,10 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions {
LiteEntity liteEntity = new LiteEntity();
liteEntityList.getListElement().add(liteEntity);
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
.thenReturn(liteEntityList);
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.ALL), eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any()))
.thenReturn(liteEntityList);
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.CHEBI_NAME),
eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any())).thenReturn(liteEntityList);
when(chebiWebServiceClient.getLiteEntity(any(), eq(SearchCategory.ALL),
eq(ChebiAnnotator.MAX_SEARCH_RESULTS_FROM_CHEBI_API), any())).thenReturn(liteEntityList);
assertEquals(ExternalServiceStatusType.CHANGED, backend.getServiceStatus().getStatus());
} catch (Exception e) {
......
......@@ -58,7 +58,7 @@
<gson.version>2.2.2</gson.version>
<chebi-ws.version>2.2.2</chebi-ws.version>
<chebi-ws.version>2.3.2</chebi-ws.version>
<miriam-lib.version>1.1.5</miriam-lib.version>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment