Skip to content

Commit

Permalink
Properly marked the IOpenToxManager methods with 'throws' clauses if …
Browse files Browse the repository at this point in the history
…the implementation does. CreateDatasetWizard and AbstractOpentoxManagerPluginTest were updated accordingly
  • Loading branch information
egonw committed May 15, 2012
1 parent e858548 commit bd06066
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 63 deletions.
Expand Up @@ -5,6 +5,7 @@
import java.util.ArrayList;
import java.util.List;

import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.core.domain.IStringMatrix;
import net.bioclipse.opentox.Activator;
import net.bioclipse.opentox.business.IOpentoxManager;
Expand Down Expand Up @@ -77,8 +78,14 @@ public List<DescriptorProvider> discoverProvidersAndImpls() {
+ provider.getService());

//Read descriptors from SPARQL using RDF in OpenTox manager
IStringMatrix stringMat = opentox.listDescriptors(
provider.getServiceSPARQL());
IStringMatrix stringMat;
try {
stringMat = opentox.listDescriptors(
provider.getServiceSPARQL());
} catch (BioclipseException e) {
e.printStackTrace();
return returnList;
}

for (int i=0; i< stringMat.getRowCount(); i++){

Expand Down
Expand Up @@ -10,7 +10,6 @@
******************************************************************************/
package net.bioclipse.opentox.test;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

import net.bioclipse.cdk.business.CDKManager;
Expand Down Expand Up @@ -40,7 +39,7 @@ public abstract class AbstractOpentoxManagerPluginTest

protected static IOpentoxManager opentox;

@Test public void testAuthentication() {
@Test public void testAuthentication() throws Exception {
opentox.logout();
Assert.assertNull(opentox.getToken());
opentox.login(TEST_ACCOUNT, TEST_ACCOUNT_PWD);
Expand All @@ -51,7 +50,7 @@ public abstract class AbstractOpentoxManagerPluginTest
Assert.assertNull(opentox.getToken());
}

@Test public void testSearchDescriptors() {
@Test public void testSearchDescriptors() throws Exception {
IStringMatrix descriptors = opentox.searchDescriptors(
TEST_SERVER_ONT, "LogP"
);
Expand All @@ -60,7 +59,7 @@ public abstract class AbstractOpentoxManagerPluginTest
Assert.assertNotSame(0, descriptors.getRowCount());
}

@Test public void testSearchModels() {
@Test public void testSearchModels() throws Exception {
IStringMatrix models = opentox.searchModels(
TEST_SERVER_ONT, "ToxTree"
);
Expand All @@ -69,7 +68,7 @@ public abstract class AbstractOpentoxManagerPluginTest
Assert.assertNotSame(0, models.getRowCount());
}

@Test public void testSearchDataSets() {
@Test public void testSearchDataSets() throws Exception {
IStringMatrix models = opentox.searchDataSets(
TEST_SERVER_ONT, "EPA"
);
Expand All @@ -78,7 +77,7 @@ public abstract class AbstractOpentoxManagerPluginTest
Assert.assertNotSame(0, models.getRowCount());
}

@Test public void testListDatasets() {
@Test public void testListDatasets() throws Exception {
List<String> sets = opentox.listDataSets(
TEST_SERVER_OT
);
Expand All @@ -87,7 +86,7 @@ public abstract class AbstractOpentoxManagerPluginTest
Assert.assertNotSame(0, sets.size());
}

@Test public void testListAlgorithms() {
@Test public void testListAlgorithms() throws Exception {
List<String> algos = opentox.listAlgorithms(
TEST_SERVER_ONT
);
Expand All @@ -96,7 +95,7 @@ public abstract class AbstractOpentoxManagerPluginTest
Assert.assertNotSame(0, algos.size());
}

@Test public void testSearchInChI() {
@Test public void testSearchInChI() throws Exception {
List<String> hits = opentox.search(
TEST_SERVER_OT,
"InChI=1/CH4/h1H4"
Expand All @@ -122,7 +121,7 @@ CDKMolecule.INCHI_OBJECT, new InChI(
Assert.assertNotSame(0, hits.size());
}

@Test public void testListDescriptors() {
@Test public void testListDescriptors() throws Exception {
IStringMatrix descriptors = opentox.listDescriptors(
TEST_SERVER_ONT
);
Expand All @@ -131,8 +130,7 @@ CDKMolecule.INCHI_OBJECT, new InChI(
Assert.assertNotSame(0, descriptors.getRowCount());
}

@Test public void testCalculateDescriptor_List_Molecule()
throws BioclipseException, InvocationTargetException {
@Test public void testCalculateDescriptor_List_Molecule() throws Exception {
IStringMatrix stringMat = opentox.listDescriptors(TEST_SERVER_ONT);

String descriptor = stringMat.get(1, "algo");
Expand All @@ -149,8 +147,7 @@ CDKMolecule.INCHI_OBJECT, new InChI(
Assert.assertSame(2, descriptorVals.size());
}

@Test public void testCalculateDescriptor()
throws BioclipseException, InvocationTargetException {
@Test public void testCalculateDescriptor() throws Exception {
IStringMatrix stringMat = opentox.listDescriptors(TEST_SERVER_ONT);

String descriptor = stringMat.get(1, "algo");
Expand Down
Expand Up @@ -9,29 +9,20 @@
package net.bioclipse.opentox.ui.wizards;


import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.List;

import net.bioclipse.browser.editors.RichBrowserEditor;
import net.bioclipse.cdk.business.ICDKManager;
import net.bioclipse.cdk.domain.ICDKMolecule;
import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.core.domain.IMolecule;
import net.bioclipse.opentox.Activator;
import net.bioclipse.opentox.business.IOpentoxManager;

import org.apache.log4j.Logger;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.widgets.Display;
Expand Down Expand Up @@ -111,21 +102,15 @@ public boolean performFinish() {
try {
getContainer().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {

try {
IOpentoxManager opentox = Activator.getDefault().getJavaOpentoxManager();
ICDKManager cdk = net.bioclipse.cdk.business.Activator.getDefault().getJavaCDKManager();

monitor.beginTask("Creating dataset: ", 10);
monitor.subTask("Parsing data file");
monitor.worked(1);
List<ICDKMolecule> mols=null;
try {
mols = cdk.loadMolecules(file, new SubProgressMonitor(monitor, 7));
} catch (Exception e) {
e.printStackTrace();
monitor.done();
return;
}

monitor.subTask("Uploading data");
monitor.worked(1);
Expand Down Expand Up @@ -167,6 +152,10 @@ public void run() {
});

monitor.done();
} catch (Exception exception) {
monitor.done();
return;
}
}
});
} catch (InvocationTargetException e) {
Expand Down

0 comments on commit bd06066

Please sign in to comment.