Skip to content
Snippets Groups Projects
Commit a4741a27 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

First commit

parents
Branches
Tags
No related merge requests found
target/
classes/
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.hint.license>nibio_open_source_license.ftl</netbeans.hint.license>
</properties>
</project-shared-configuration>
pom.xml 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>no.nibio.vips.model</groupId>
<artifactId>PsilaRosaeObservationModel</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>no.nibio.vips.common</groupId>
<artifactId>VIPSCommon</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
/*
* Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
*
* This file is part of PsilaRosaeObservationModel.
* PsilaRosaeObservationModel is free software: you can redistribute it and/or modify
* it under the terms of the NIBIO Open Source License as published by
* NIBIO, either version 1 of the License, or (at your option) any
* later version.
*
* PsilaRosaeObservationModel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* NIBIO Open Source License for more details.
*
* You should have received a copy of the NIBIO Open Source License
* along with PsilaRosaeObservationModel. If not, see <http://www.nibio.no/licenses/>.
*
*/
package no.nibio.vips.model.psilarosaeobservationmodel;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import no.nibio.vips.entity.ModelConfiguration;
import no.nibio.vips.entity.Result;
import no.nibio.vips.entity.ResultImpl;
import no.nibio.vips.i18n.I18nImpl;
import no.nibio.vips.model.ConfigValidationException;
import no.nibio.vips.model.Model;
import no.nibio.vips.model.ModelExcecutionException;
import no.nibio.vips.model.ModelId;
import no.nibio.vips.observation.Observation;
import no.nibio.vips.observation.ObservationImpl;
import no.nibio.vips.util.ModelUtil;
import no.nibio.vips.util.WeatherUtil;
/**
* @copyright 2016 <a href="http://www.nibio.no/">NIBIO</a>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/
public class PsilaRosaeObservationModel extends I18nImpl implements Model{
public final static ModelId MODEL_ID = new ModelId("PSILAROBSE");
public final static String TRAP_COUNT_CROP_EDGE = "trapCountCropEdge";
public final static String TRAP_COUNT_CROP_INSIDE = "trapCountCropInside";
private final Integer observationMaximumValidDays = 9;
private ObjectMapper objectMapper;
private final ModelUtil modelUtil;
private final WeatherUtil weatherUtil;
private List<Observation> pestObservations;
private TimeZone timeZone;
private Date startDateCalculation;
private Date endDateCalculation;
public PsilaRosaeObservationModel()
{
super("no.nibio.vips.model.psilarosaeobservationmodel.texts");
this.modelUtil = new ModelUtil();
this.weatherUtil = new WeatherUtil();
}
@Override
public List<Result> getResult() throws ModelExcecutionException {
List<Result> retVal = new ArrayList<>();
Calendar cal = Calendar.getInstance(timeZone);
Date currentDate = this.startDateCalculation;
while(currentDate.compareTo(endDateCalculation) <= 0)
{
Result result = new ResultImpl();
result.setResultValidTime(currentDate);
// Setting result data
Observation todayObs = getObservationAtDate(currentDate);
if(todayObs != null)
{
Map<String, Integer> data = this.getPestObservationValues(todayObs.getObservationData());
result.setValue(this.getModelId().toString(), "TRAP_COUNT_CROP_EDGE",
String.valueOf(data.get(PsilaRosaeObservationModel.TRAP_COUNT_CROP_EDGE))
);
result.setValue(this.getModelId().toString(), "TRAP_COUNT_CROP_INSIDE",
String.valueOf(data.get(PsilaRosaeObservationModel.TRAP_COUNT_CROP_INSIDE))
);
}
result.setValue(this.getModelId().toString(), "TRAP_COUNT_THRESHOLD","1");
// Deciding warning status
Observation latestObs = getObservationValidForDate(currentDate);
if(latestObs == null)
{
result.setWarningStatus(Result.WARNING_STATUS_NO_WARNING_MISSING_DATA);
}
else
{
result.setWarningStatus(Result.WARNING_STATUS_NO_RISK);
Map<String, Integer> data = this.getPestObservationValues(latestObs.getObservationData());
Integer trapCountCropEdge = data.get(PsilaRosaeObservationModel.TRAP_COUNT_CROP_EDGE);
Integer trapCountCropInside = data.get(PsilaRosaeObservationModel.TRAP_COUNT_CROP_INSIDE);
if(trapCountCropEdge > 0)
{
result.setWarningStatus(Result.WARNING_STATUS_MINOR_RISK);
}
if(trapCountCropInside > 0)
{
result.setWarningStatus(Result.WARNING_STATUS_HIGH_RISK);
}
}
retVal.add(result);
// Move forward in time
cal.setTime(currentDate);
cal.add(Calendar.DATE, 1);
currentDate = cal.getTime();
}
return retVal;
}
@Override
public ModelId getModelId() {
return PsilaRosaeObservationModel.MODEL_ID;
}
@Override
public String getModelName() {
return this.getModelName(Model.DEFAULT_LANGUAGE);
}
@Override
public String getModelName(String language) {
return this.getText("name", language);
}
@Override
public String getLicense() {
return "Copyright (c) 2016 NIBIO <http://www.nibio.no/>. \n" +
"\n" +
"This file is part of PsilaRosaeObservationModel. \n" +
"PsilaRosaeObservationModel is free software: you can redistribute it and/or modify \n" +
"it under the terms of the NIBIO Open Source License as published by \n" +
"NIBIO, either version 1 of the License, or (at your option) any \n" +
"later version. \n" +
"\n" +
"PsilaRosaeObservationModel is distributed in the hope that it will be useful, \n" +
"but WITHOUT ANY WARRANTY; without even the implied warranty of \n" +
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \n" +
"NIBIO Open Source License for more details. \n" +
"" +
"You should have received a copy of the NIBIO Open Source License \n" +
"along with PsilaRosaeObservationModel. If not, see <http://www.nibio.no/licenses/>. \n";
}
@Override
public String getCopyright() {
return "(c) 2016 NIBIO (http://www.nibio.no/). Contact: post@nibio.no";
}
@Override
public String getModelDescription() {
return this.getModelDescription(Model.DEFAULT_LANGUAGE);
}
@Override
public String getModelDescription(String language) {
try
{
return this.modelUtil.getTextWithBase64EncodedImages(this.getText("description", language), this.getClass());
}
catch(IOException ex)
{
return this.getText("description", language);
}
}
@Override
public String getWarningStatusInterpretation() {
return this.getWarningStatusInterpretation(Model.DEFAULT_LANGUAGE);
}
@Override
public String getWarningStatusInterpretation(String language) {
return this.getText("statusInterpretation", language);
}
@Override
public String getModelUsage() {
return this.getModelUsage(Model.DEFAULT_LANGUAGE);
}
@Override
public String getModelUsage(String language) {
return this.getText("usage", language);
}
@Override
public String getSampleConfig() {
return "{\n" +
"\t\"loginInfo\":{\n" +
"\t\t\"username\":\"example\",\n" +
"\t\t\"password\":\"example\"\n" +
"\t},\n" +
"\t\"modelId\":\"" + MODEL_ID.toString() + "\",\n" +
"\t\"configParameters\":{\n" +
"\t\t\"timeZone\":\"Europe/Oslo\",\n" +
"\t\t\"startDateCalculation\":\"2012-03-25\",\n" +
"\t\t\"endDateCalculation\":\"2012-03-25\",\n" +
"\t\t\"pestObservations\":[\n" +
"\t\t\t{" +
"\t\t\t\t\"timeOfObservation\":\"2016-04-20T00:00:00+02:00\"," +
"\t\t\t\t\"observationData\":{" +
"\t\t\t\t\t\"trapCountCropEdge\":3," +
"\t\t\t\t\t\"trapCountCropInside\":2" +
"\t\t\t\t}" +
"\t\t\t\"}," +
"\t\t\t{" +
"\t\t\t\t\"timeOfObservation\":\"2016-04-25T00:00:00+02:00\"," +
"\t\t\t\t\"observationData\":{" +
"\t\t\t\t\t\"trapCountCropEdge\":0," +
"\t\t\t\t\t\"trapCountCropInside\":0" +
"\t\t\t\t}" +
"\t\t\t\"}" +
"\t\t]\n" +
"\t}\n" +
"}\n";
}
@Override
public void setConfiguration(ModelConfiguration config) throws ConfigValidationException {
this.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
this.pestObservations = this.getObjectMapper().convertValue(config.getConfigParameter("pestObservations"), new TypeReference<List<ObservationImpl>>(){});
if(this.pestObservations == null || this.pestObservations.isEmpty())
{
throw new ConfigValidationException("ERROR: No observations");
}
Collections.sort(this.pestObservations);
// Setting timezone
this.timeZone = TimeZone.getTimeZone((String) config.getConfigParameter("timeZone"));
String[] dateparts;
String dateParameter = "";
try
{
dateParameter = "startDateCalculation";
dateparts = config.getConfigParameter(dateParameter).toString().split("-");
dateParameter = "endDateCalculation";
dateparts = config.getConfigParameter(dateParameter).toString().split("-");
}
catch (NullPointerException ex){
throw new ConfigValidationException(dateParameter + " not set");
}
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
format.setTimeZone(timeZone);
try
{
dateParameter = "startDateCalculation";
this.startDateCalculation = format.parse(config.getConfigParameter("startDateCalculation").toString());
dateParameter = "endDateCalculation";
this.endDateCalculation = format.parse(config.getConfigParameter("endDateCalculation").toString());
}
catch(ParseException | NullPointerException ex)
{
throw new ConfigValidationException("Illegal date format for " + dateParameter + ": " + config.getConfigParameter(dateParameter));
}
}
private ObjectMapper getObjectMapper()
{
if(this.objectMapper == null)
{
this.objectMapper = new ObjectMapper();
}
return this.objectMapper;
}
public Observation getObservationAtDate(Date currentDate) {
for(Observation obs:this.pestObservations)
{
if(this.weatherUtil.normalizeToExactDate(obs.getTimeOfObservation(), timeZone).compareTo(currentDate) == 0)
{
return obs;
}
}
return null;
}
/**
* Parses the JSON and returns the average number
* @param observationData
* @return
*/
public Map<String, Integer> getPestObservationValues(String observationData)
{
try
{
Map<String, Integer> data = this.getObjectMapper().readValue(new ByteArrayInputStream(observationData.getBytes("UTF-8")), new TypeReference<HashMap<String,Integer>>() {});
return data;
}
catch(IOException ex)
{
return null;
}
}
public Observation getObservationValidForDate(Date currentDate) {
Long currentTime = currentDate.getTime();
Observation currentObservation = null;
for(Observation obs:this.pestObservations)
{
Long obsTime = this.weatherUtil.normalizeToExactDate(obs.getTimeOfObservation(), timeZone).getTime();
if( currentTime - obsTime >= 0 // Must be before the current date
&& currentTime - obsTime < this.observationMaximumValidDays * (24 * 3600 * 1000) // Must be maximum [9] days before current date
&& (currentObservation == null || currentTime - obsTime < currentTime - currentObservation.getTimeOfObservation().getTime()) // Must be closer to current date than any other observations
)
{
currentObservation = obs;
}
}
return currentObservation;
}
}
# Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
#
# This file is part of MamestraBrassicaeModel.
# MamestraBrassicaeModel is free software: you can redistribute it and/or modify
# it under the terms of the NIBIO Open Source License as published by
# NIBIO, either version 1 of the License, or (at your option) any
# later version.
#
# MamestraBrassicaeModel is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# NIBIO Open Source License for more details.
#
# You should have received a copy of the NIBIO Open Source License
# along with MamestraBrassicaeModel. If not, see <http://www.nibio.no/licenses/>.
#
name=Psila rosae observation model
description=TODO
statusInterpretation=TODO
usage=TODO
name=Gulrotflue observasjonsmodell
description=TODO
statusInterpretation=TODO
usage=TODO
/*
* Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
*
* This file is part of PsilaRosaeObservationModel.
* PsilaRosaeObservationModel is free software: you can redistribute it and/or modify
* it under the terms of the NIBIO Open Source License as published by
* NIBIO, either version 1 of the License, or (at your option) any
* later version.
*
* PsilaRosaeObservationModel is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* NIBIO Open Source License for more details.
*
* You should have received a copy of the NIBIO Open Source License
* along with PsilaRosaeObservationModel. If not, see <http://www.nibio.no/licenses/>.
*
*/
package no.nibio.vips.model.psilarosaeobservationmodel;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import no.nibio.vips.entity.ModelConfiguration;
import no.nibio.vips.entity.Result;
import no.nibio.vips.model.ModelId;
import no.nibio.vips.observation.Observation;
import no.nibio.vips.observation.ObservationImpl;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author treinar
*/
public class PsilaRosaeObservationModelTest {
public PsilaRosaeObservationModelTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getResult method, of class PsilaRosaeObservationModel.
*/
@Test
public void testGetResult() throws Exception {
System.out.println("getResult");
PsilaRosaeObservationModel instance = new PsilaRosaeObservationModel();
ModelConfiguration config = new ModelConfiguration();
String tzID="Europe/Oslo";
TimeZone timeZone = TimeZone.getTimeZone(tzID);
config.setConfigParameter("timeZone", tzID);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
format.setTimeZone(timeZone);
config.setConfigParameter("startDateCalculation", "2016-04-01");
config.setConfigParameter("endDateCalculation", "2016-06-01");
List<Observation> pestObservations = new ArrayList<>();
ObservationImpl obs1 = new ObservationImpl();
obs1.setTimeOfObservation(format.parse("2016-04-20"));
obs1.setObservationData("{\"trapCountCropEdge\":3,\"trapCountCropInside\":0}");
pestObservations.add(obs1);
ObservationImpl obs2 = new ObservationImpl();
obs2.setTimeOfObservation(format.parse("2016-04-24"));
obs2.setObservationData("{\"trapCountCropEdge\":1,\"trapCountCropInside\":5}");
pestObservations.add(obs2);
config.setConfigParameter("pestObservations", pestObservations);
instance.setConfiguration(config);
List<Result> result = instance.getResult();
System.out.println("Number of results returned: " + result.size());
for(Result res:result)
{
System.out.println(res);
}
assertNotNull(result);
}
/**
* Test of getModelId method, of class PsilaRosaeObservationModel.
*/
@Test
public void testGetModelId() {
System.out.println("getModelId");
PsilaRosaeObservationModel instance = new PsilaRosaeObservationModel();
String expResult = "PSILAROBSE";
ModelId result = instance.getModelId();
assertEquals(expResult, result.toString());
}
/**
* Test of getModelName method, of class PsilaRosaeObservationModel.
*/
@Test
public void testGetModelName_0args() {
System.out.println("getModelName");
PsilaRosaeObservationModel instance = new PsilaRosaeObservationModel();
String result = instance.getModelName();
assertNotNull(result);
}
/**
* Test of getLicense method, of class PsilaRosaeObservationModel.
*/
@Test
public void testGetLicense() {
System.out.println("getLicense");
PsilaRosaeObservationModel instance = new PsilaRosaeObservationModel();
String result = instance.getLicense();
assertNotNull(result);
}
/**
* Test of getCopyright method, of class PsilaRosaeObservationModel.
*/
@Test
public void testGetCopyright() {
System.out.println("getCopyright");
PsilaRosaeObservationModel instance = new PsilaRosaeObservationModel();
String result = instance.getCopyright();
assertNotNull(result);
}
/**
* Test of getModelDescription method, of class PsilaRosaeObservationModel.
*/
@Test
public void testGetModelDescription_0args() {
System.out.println("getModelDescription");
PsilaRosaeObservationModel instance = new PsilaRosaeObservationModel();
String result = instance.getModelDescription();
assertNotNull(result);
}
/**
* Test of getWarningStatusInterpretation method, of class PsilaRosaeObservationModel.
*/
@Test
public void testGetWarningStatusInterpretation_0args() {
System.out.println("getWarningStatusInterpretation");
PsilaRosaeObservationModel instance = new PsilaRosaeObservationModel();
String result = instance.getWarningStatusInterpretation();
assertNotNull(result);
}
/**
* Test of getModelUsage method, of class PsilaRosaeObservationModel.
*/
@Test
public void testGetModelUsage_0args() {
System.out.println("getModelUsage");
PsilaRosaeObservationModel instance = new PsilaRosaeObservationModel();
String result = instance.getModelUsage();
assertNotNull(result);
}
/**
* Test of getSampleConfig method, of class PsilaRosaeObservationModel.
*/
@Test
public void testGetSampleConfig() {
System.out.println("getSampleConfig");
PsilaRosaeObservationModel instance = new PsilaRosaeObservationModel();
String result = instance.getSampleConfig();
assertNotNull(result);
}
/**
* Test of getObservationAtDate method, of class PsilaRosaeObservationModel.
*/
@Test
public void testGetObservationAtDate() throws Exception{
System.out.println("getObservationAtDate");
PsilaRosaeObservationModel instance = new PsilaRosaeObservationModel();
ModelConfiguration config = new ModelConfiguration();
String tzID="Europe/Oslo";
TimeZone timeZone = TimeZone.getTimeZone(tzID);
config.setConfigParameter("timeZone", tzID);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
format.setTimeZone(timeZone);
config.setConfigParameter("startDateCalculation", "2016-04-01");
config.setConfigParameter("endDateCalculation", "2016-06-01");
List<Observation> pestObservations = new ArrayList<>();
ObservationImpl obs1 = new ObservationImpl();
obs1.setTimeOfObservation(format.parse("2016-04-20"));
obs1.setObservationData("{\"trapCountCropEdge\":1,\"trapCountCropInside\":5}");
pestObservations.add(obs1);
/*ObjectMapper om = new ObjectMapper();
System.out.println(om.writeValueAsString(obs1));*/
ObservationImpl obs2 = new ObservationImpl();
obs2.setTimeOfObservation(format.parse("2016-04-24"));
obs2.setObservationData("{\"trapCountCropEdge\":0,\"trapCountCropInside\":0}");
pestObservations.add(obs2);
config.setConfigParameter("pestObservations", pestObservations);
instance.setConfiguration(config);
Date testDate = format.parse("2016-04-21");
Observation obs = instance.getObservationAtDate(testDate);
assertNull(obs);
testDate = format.parse("2016-04-25");
obs = instance.getObservationAtDate(testDate);
assertNull(obs);
testDate = format.parse("2016-04-19");
obs = instance.getObservationAtDate(testDate);
assertNull(obs);
testDate = format.parse("2016-04-20");
obs = instance.getObservationAtDate(testDate);
assertEquals(testDate,obs.getTimeOfObservation());
}
/**
* Test of getPestObservationValues method, of class PsilaRosaeObservationModel.
*/
@Test
public void testGetPestObservationValues() {
System.out.println("getPestObservationValues");
String observationData = "{\"trapCountCropEdge\":1,\"trapCountCropInside\":5}";
Integer expRes1 = 1;
Integer expRes2 = 5;
PsilaRosaeObservationModel instance = new PsilaRosaeObservationModel();
Map<String, Integer> result = instance.getPestObservationValues(observationData);
assertEquals(expRes1, result.get(PsilaRosaeObservationModel.TRAP_COUNT_CROP_EDGE));
assertEquals(expRes2, result.get(PsilaRosaeObservationModel.TRAP_COUNT_CROP_INSIDE));
}
/**
* Test of getObservationValidForDate method, of class PsilaRosaeObservationModel.
* @throws java.lang.Exception
*/
@Test
public void testGetObservationValidForDate() throws Exception{
System.out.println("getObservationValidForDate");
PsilaRosaeObservationModel instance = new PsilaRosaeObservationModel();
ModelConfiguration config = new ModelConfiguration();
String tzID="Europe/Oslo";
TimeZone timeZone = TimeZone.getTimeZone(tzID);
config.setConfigParameter("timeZone", tzID);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
format.setTimeZone(timeZone);
config.setConfigParameter("startDateCalculation", "2016-04-01");
config.setConfigParameter("endDateCalculation", "2016-06-01");
List<Observation> pestObservations = new ArrayList<>();
ObservationImpl obs1 = new ObservationImpl();
obs1.setTimeOfObservation(format.parse("2016-04-20"));
obs1.setObservationData("{\"trapCountCropEdge\":0,\"trapCountCropInside\":0}");
pestObservations.add(obs1);
ObservationImpl obs2 = new ObservationImpl();
obs2.setTimeOfObservation(format.parse("2016-04-24"));
obs2.setObservationData("{\"trapCountCropEdge\":1,\"trapCountCropInside\":5}");
pestObservations.add(obs2);
config.setConfigParameter("pestObservations", pestObservations);
instance.setConfiguration(config);
Date testDate = format.parse("2016-04-21");
Observation obs = instance.getObservationValidForDate(testDate);
assertEquals(format.parse("2016-04-20"), obs.getTimeOfObservation());
testDate = format.parse("2016-04-25");
obs = instance.getObservationValidForDate(testDate);
assertEquals(format.parse("2016-04-24"), obs.getTimeOfObservation());
testDate = format.parse("2016-04-19");
obs = instance.getObservationValidForDate(testDate);
assertNull(obs);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment