mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 22:43:57 +00:00
Added unit test for WindEstimationDataClient (yet without
wind_estimation_data)
This commit is contained in:
1 parent
d213ee8500
commit
8f2dd7f0d8
3 files changed
+71
-3
No files matched your search
+33
@@ -0,0 +1,33 @@
|
||||
package com.sap.sailing.windestimation.jaxrs.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import com.sap.sailing.windestimation.integration.ReplicableWindEstimationFactoryService;
|
||||
import com.sap.sailing.windestimation.jaxrs.client.WindEstimationDataClient;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Vladislav Chumak (D069712)
|
||||
*
|
||||
*/
|
||||
public class WindEstimationDataClientMock extends WindEstimationDataClient {
|
||||
|
||||
private final File file;
|
||||
|
||||
public WindEstimationDataClientMock(File file,
|
||||
ReplicableWindEstimationFactoryService windEstimationFactoryService) {
|
||||
super(null, windEstimationFactoryService);
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InputStream getContentFromResponse() throws IOException, ParseException {
|
||||
return new FileInputStream(file);
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.sap.sailing.windestimation.jaxrs.api;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.polars.NotEnoughDataHasBeenAddedException;
|
||||
import com.sap.sailing.windestimation.integration.WindEstimationFactoryServiceImpl;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Vladislav Chumak (D069712)
|
||||
*
|
||||
*/
|
||||
public class WindEstimationDataResourceTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testImportingFromMockFile() throws NotEnoughDataHasBeenAddedException, ClassNotFoundException,
|
||||
IOException, ParseException, InterruptedException {
|
||||
WindEstimationFactoryServiceImpl windEstimationFactoryService = new WindEstimationFactoryServiceImpl();
|
||||
assertFalse(windEstimationFactoryService.isReady());
|
||||
final WindEstimationDataClientMock client = new WindEstimationDataClientMock(
|
||||
new File("resources/wind_estimation_data"), windEstimationFactoryService);
|
||||
client.updateWindEstimationModels();
|
||||
assertTrue(windEstimationFactoryService.isReady());
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -88,10 +88,10 @@ public class Activator implements BundleActivator {
|
||||
|
||||
private void importWindEstimationModelsFromUrl(String windEstimationModelDataSourceURL) {
|
||||
logger.info("Importing wind estimation data from URL: " + windEstimationModelDataSourceURL);
|
||||
WindEstimationDataClient polarDataClient = new WindEstimationDataClient(windEstimationModelDataSourceURL,
|
||||
service);
|
||||
WindEstimationDataClient windEstimationDataClient = new WindEstimationDataClient(
|
||||
windEstimationModelDataSourceURL, service);
|
||||
try {
|
||||
polarDataClient.updateWindEstimationModels();
|
||||
windEstimationDataClient.updateWindEstimationModels();
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE, "Exception while trying to import wind estimation model data from "
|
||||
+ windEstimationModelDataSourceURL, e);
|
||||
|
||||
Reference in new issue
Block a user