Skip to content

Commit

Permalink
Fixed bug in TestHelper Implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
tabergma committed Aug 20, 2014
1 parent e2481a0 commit bfda0d0
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.google.common.annotations.GwtIncompatible;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Entity;
Expand All @@ -33,8 +34,9 @@
*/
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Input {
public class Input implements Serializable {

private static final long serialVersionUID = 7392272000742912206L;
protected long id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void onSuccess(List<DatabaseConnection> result) {

if (result != null && result.size() > 0) {
for (DatabaseConnection db : result) {
String identifier = db.getId() + ": " + db.getUrl(); // TODO add system
String identifier = db.getUrl(); // TODO add system
dbConnectionNames.add(identifier);
databaseConnections.put(identifier, db);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import de.uni_potsdam.hpi.metanome.results_db.Algorithm;
import de.uni_potsdam.hpi.metanome.results_db.DatabaseConnection;
import de.uni_potsdam.hpi.metanome.results_db.FileInput;
import de.uni_potsdam.hpi.metanome.results_db.TableInput;
import de.uni_potsdam.hpi.metanome.results_db.Input;

import java.util.List;

Expand All @@ -44,8 +44,8 @@ public interface TestDatabaseHelperService extends RemoteService {

List<DatabaseConnection> getAllDatabaseConnections();

List<TableInput> getAllTableInputs();
List<Input> getAllTableInputs();

List<FileInput> getAllFileInputs();
List<Input> getAllFileInputs();

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import de.uni_potsdam.hpi.metanome.results_db.Algorithm;
import de.uni_potsdam.hpi.metanome.results_db.DatabaseConnection;
import de.uni_potsdam.hpi.metanome.results_db.FileInput;
import de.uni_potsdam.hpi.metanome.results_db.TableInput;
import de.uni_potsdam.hpi.metanome.results_db.Input;

import java.util.List;

Expand All @@ -40,9 +40,9 @@ public interface TestDatabaseHelperServiceAsync {

void getAllDatabaseConnections(AsyncCallback<List<DatabaseConnection>> async);

void getAllTableInputs(AsyncCallback<List<TableInput>> async);
void getAllTableInputs(AsyncCallback<List<Input>> async);

void getAllFileInputs(AsyncCallback<List<FileInput>> async);
void getAllFileInputs(AsyncCallback<List<Input>> async);

void storeFileInput(FileInput input, AsyncCallback<Long> async);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import de.uni_potsdam.hpi.metanome.results_db.EntityStorageException;
import de.uni_potsdam.hpi.metanome.results_db.FileInput;
import de.uni_potsdam.hpi.metanome.results_db.HibernateUtil;
import de.uni_potsdam.hpi.metanome.results_db.Input;
import de.uni_potsdam.hpi.metanome.results_db.TableInput;

import java.util.List;
Expand Down Expand Up @@ -93,19 +94,19 @@ public List<DatabaseConnection> getAllDatabaseConnections() {
}

@Override
public List<TableInput> getAllTableInputs() {
public List<Input> getAllTableInputs() {
try {
TableInput.retrieveAll();
return TableInput.retrieveAll();
} catch (EntityStorageException e) {
e.printStackTrace();
}
return null;
}

@Override
public List<FileInput> getAllFileInputs() {
public List<Input> getAllFileInputs() {
try {
FileInput.retrieveAll();
return FileInput.retrieveAll();
} catch (EntityStorageException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import de.uni_potsdam.hpi.metanome.results_db.Algorithm;
import de.uni_potsdam.hpi.metanome.results_db.DatabaseConnection;
import de.uni_potsdam.hpi.metanome.results_db.FileInput;
import de.uni_potsdam.hpi.metanome.results_db.TableInput;
import de.uni_potsdam.hpi.metanome.results_db.Input;

import java.util.List;

Expand Down Expand Up @@ -113,6 +113,7 @@ public void onFailure(Throwable caught) {
@Override
public void onSuccess(Long result) {
database_connection_blocked[0] = false;
System.out.println("Database Connection saved!");
}
});

Expand Down Expand Up @@ -142,6 +143,7 @@ public void onFailure(Throwable caught) {
@Override
public void onSuccess(Long result) {
file_input_blocked[0] = false;
System.out.println("File Input saved!");
}
});

Expand All @@ -168,15 +170,15 @@ public static void getAllDatabaseConnections(AsyncCallback<List<DatabaseConnecti
* Get all file inputs synchronously.
* @param callback the async callback
*/
public static void getAllFileInputs(AsyncCallback<List<FileInput>> callback) {
public static void getAllFileInputs(AsyncCallback<List<Input>> callback) {
testDatabaseHelperService.getAllFileInputs(callback);
}

/**
* Get all table inputs synchronously.
* @param callback the async callback
*/
public static void getAllTableInputs(AsyncCallback<List<TableInput>> callback) {
public static void getAllTableInputs(AsyncCallback<List<Input>> callback) {
testDatabaseHelperService.getAllTableInputs(callback);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import de.uni_potsdam.hpi.metanome.results_db.DatabaseConnection;
import de.uni_potsdam.hpi.metanome.results_db.EntityStorageException;
import de.uni_potsdam.hpi.metanome.results_db.FileInput;
import de.uni_potsdam.hpi.metanome.results_db.Input;
import de.uni_potsdam.hpi.metanome.results_db.TableInput;

import java.util.List;
Expand Down Expand Up @@ -103,7 +104,7 @@ public void run() {
public void run() {
// Check result
TestHelper.getAllTableInputs(
new AsyncCallback<List<TableInput>>() {
new AsyncCallback<List<Input>>() {
@Override
public void onFailure(Throwable throwable) {
fail();
Expand All @@ -112,8 +113,11 @@ public void onFailure(Throwable throwable) {
}

@Override
public void onSuccess(List<TableInput> con) {
assertTrue(con.contains(expectedInput[0]));
public void onSuccess(List<Input> con) {
TableInput actualInput = (TableInput) con.get(0);
assertEquals(expectedInput[0].getDatabaseConnection(), actualInput.getDatabaseConnection());
assertEquals(expectedInput[0].getTableName(), actualInput.getTableName());

// Cleanup
TestHelper.resetDatabaseSync();
finishTest();
Expand All @@ -122,10 +126,10 @@ public void onSuccess(List<TableInput> con) {
}
};

executeTimer.schedule(1000);
checkTimer.schedule(2000);
executeTimer.schedule(2000);
checkTimer.schedule(4000);

delayTestFinish(3000);
delayTestFinish(6000);
}

/**
Expand Down Expand Up @@ -158,7 +162,7 @@ public void testStoreFileInput() throws EntityStorageException, InputValidationE
@Override
public void run() {
TestHelper.getAllFileInputs(
new AsyncCallback<List<FileInput>>() {
new AsyncCallback<List<Input>>() {
@Override
public void onFailure(Throwable throwable) {
fail();
Expand All @@ -167,9 +171,8 @@ public void onFailure(Throwable throwable) {
}

@Override
public void onSuccess(List<FileInput> con) {
FileInput input = con.get(0);

public void onSuccess(List<Input> con) {
FileInput input = (FileInput) con.get(0);
assertEquals(expectedInput.getFileName(), input.getFileName());

// Cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public void run() {

// Waiting four seconds for asynchronous calls to finish.
// Validate, if expected and actual objects are equal
timer.schedule(1000);
timer.schedule(2000);

delayTestFinish(2000);
delayTestFinish(4000);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ public void run() {
// Waiting for asynchronous calls to finish.
executeTimer.schedule(2000);

delayTestFinish(3000);
delayTestFinish(4000);
}

private void setCsvFile(InputParameterCsvFileWidget widget) {
for (CsvFileInput csvFileInput : widget.inputWidgets) {
csvFileInput.listbox.setSelectedValue("1: name");
csvFileInput.listbox.setSelectedValue("name");
}
}

Expand All @@ -224,7 +224,7 @@ private void enterNumber(InputParameterIntegerWidget widget) {

private void setDatabaseConnection(InputParameterSqlIteratorWidget widget) {
for (SqlIteratorInput sqlIteratorInput : widget.inputWidgets) {
sqlIteratorInput.listbox.setSelectedValue("1: url");
sqlIteratorInput.listbox.setSelectedValue("url");
}
}

Expand Down Expand Up @@ -378,7 +378,6 @@ public void run() {
try {
for (ConfigurationSpecification dataSource : pt.getConfigurationSpecificationDataSourcesWithValues()){
for (Object setting : dataSource.getSettings()) {
System.out.println(((ConfigurationSettingDataSource) setting).getValueAsString() + " vs " + primaryDataSource.getValueAsString());
if(((ConfigurationSettingDataSource) setting).getValueAsString().equals(primaryDataSource.getValueAsString()))
foundDataSource = true;
}
Expand All @@ -401,9 +400,9 @@ public void run() {
}
};
// Waiting for asynchronous calls to finish.
executeTimer.schedule(1000);
executeTimer.schedule(2000);

delayTestFinish(2000);
delayTestFinish(4000);
}


Expand Down

0 comments on commit bfda0d0

Please sign in to comment.