Issue #2386 Added unit tests to cover full test procedures in ticket 2386 and fixed issues.
Amend: updated test envlope sizes. fixed ticket numbers in software history. Change-Id: Id2fa1638d31e3b03092587769063123c838c49c5 Former-commit-id:794bbc3c9b
[formerly36a24c1cb5
[formerly 4c3148df4e85ccfa1d5b123fcb605d97249833d7]] Former-commit-id:36a24c1cb5
Former-commit-id:49ddffc99b
This commit is contained in:
parent
1d57e9f5f7
commit
b0f71efecc
8 changed files with 1140 additions and 459 deletions
|
@ -39,6 +39,7 @@ import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOver
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Oct 17, 2013 2292 mpduff Initial creation
|
* Oct 17, 2013 2292 mpduff Initial creation
|
||||||
|
* Feb 13, 2014 2386 bgonzale Change pass comparisons to >= instead of only >.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -59,10 +60,10 @@ public class GridOverlapData<T extends GriddedTime, C extends GriddedCoverage>
|
||||||
private int cycleDuplication = -999;
|
private int cycleDuplication = -999;
|
||||||
|
|
||||||
/** Forecast hour pass flag */
|
/** Forecast hour pass flag */
|
||||||
private boolean fcstHrPass = false;
|
protected boolean fcstHrPass = false;
|
||||||
|
|
||||||
/** Cycle time pass flag */
|
/** Cycle time pass flag */
|
||||||
private boolean cyclePass = false;
|
protected boolean cyclePass = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -122,10 +123,10 @@ public class GridOverlapData<T extends GriddedTime, C extends GriddedCoverage>
|
||||||
calculateForecastHourDuplicationPercent(sub1, sub2);
|
calculateForecastHourDuplicationPercent(sub1, sub2);
|
||||||
GridSubscriptionOverlapConfig config = (GridSubscriptionOverlapConfig) this.config;
|
GridSubscriptionOverlapConfig config = (GridSubscriptionOverlapConfig) this.config;
|
||||||
|
|
||||||
fcstHrPass = fcstHrDuplication > config
|
fcstHrPass = fcstHrDuplication >= config
|
||||||
.getMaxAllowedForecastHourDuplication();
|
.getMaxAllowedForecastHourDuplication();
|
||||||
|
|
||||||
cyclePass = cycleDuplication > config.getMaxAllowedCycleDuplication();
|
cyclePass = cycleDuplication >= config.getMaxAllowedCycleDuplication();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,6 +46,7 @@ import com.raytheon.uf.common.util.CollectionUtil;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Oct 17, 2013 2292 mpduff Initial creation
|
* Oct 17, 2013 2292 mpduff Initial creation
|
||||||
|
* Feb 13, 2014 2386 bgonzale Change pass comparisons to >= instead of only >.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -161,10 +162,10 @@ public abstract class OverlapData<T extends Time, C extends Coverage> {
|
||||||
protected void determineOverlapping() {
|
protected void determineOverlapping() {
|
||||||
calculateParameterDuplicationPercent(sub1, sub2);
|
calculateParameterDuplicationPercent(sub1, sub2);
|
||||||
calculateSpatialDuplicationPercent(sub1, sub2);
|
calculateSpatialDuplicationPercent(sub1, sub2);
|
||||||
this.parameterPass = this.parameterDuplication > config
|
this.parameterPass = this.parameterDuplication >= config
|
||||||
.getMaxAllowedParameterDuplication();
|
.getMaxAllowedParameterDuplication();
|
||||||
|
|
||||||
this.spatialPass = this.spatialDuplication > config
|
this.spatialPass = this.spatialDuplication >= config
|
||||||
.getMaxAllowedSpatialDuplication();
|
.getMaxAllowedSpatialDuplication();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,9 @@ import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOver
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Oct 17, 2013 2292 mpduff Initial creation
|
* Oct 17, 2013 2292 mpduff Initial creation
|
||||||
|
* Feb 13, 2014 2386 bgonzale Change pass comparisons to >= instead of only >.
|
||||||
|
* Change halfNumAttrs comp to a double for comparisons
|
||||||
|
* against half of uneven numbers of attributes.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -55,7 +58,7 @@ public class PointOverlapData<T extends PointTime, C extends Coverage> extends
|
||||||
private int timeDuplication = -999;
|
private int timeDuplication = -999;
|
||||||
|
|
||||||
/** Time duplication pass flag */
|
/** Time duplication pass flag */
|
||||||
private boolean timeDuplicationPass = false;
|
protected boolean timeDuplicationPass = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -98,7 +101,7 @@ public class PointOverlapData<T extends PointTime, C extends Coverage> extends
|
||||||
super.determineOverlapping();
|
super.determineOverlapping();
|
||||||
PointSubscriptionOverlapConfig config = (PointSubscriptionOverlapConfig) this.config;
|
PointSubscriptionOverlapConfig config = (PointSubscriptionOverlapConfig) this.config;
|
||||||
calculateTimeDuplicationPercent(sub1, sub2);
|
calculateTimeDuplicationPercent(sub1, sub2);
|
||||||
this.timeDuplicationPass = this.timeDuplication > config
|
this.timeDuplicationPass = this.timeDuplication >= config
|
||||||
.getMaxAllowedTimeDuplication();
|
.getMaxAllowedTimeDuplication();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +120,7 @@ public class PointOverlapData<T extends PointTime, C extends Coverage> extends
|
||||||
response = this.parameterPass || this.spatialPass
|
response = this.parameterPass || this.spatialPass
|
||||||
|| this.timeDuplicationPass;
|
|| this.timeDuplicationPass;
|
||||||
} else if (matchStrategy == SubscriptionOverlapMatchStrategy.AT_LEAST_HALF) {
|
} else if (matchStrategy == SubscriptionOverlapMatchStrategy.AT_LEAST_HALF) {
|
||||||
int halfNumAttrs = (numberOfPointAttributes + numberOfCommonAttributes) / 2;
|
double halfNumAttrs = (numberOfPointAttributes + numberOfCommonAttributes) / 2.0;
|
||||||
List<Boolean> toCheck = new ArrayList<Boolean>(3);
|
List<Boolean> toCheck = new ArrayList<Boolean>(3);
|
||||||
toCheck.add(timeDuplicationPass);
|
toCheck.add(timeDuplicationPass);
|
||||||
toCheck.add(spatialPass);
|
toCheck.add(spatialPass);
|
||||||
|
|
|
@ -35,6 +35,7 @@ import com.raytheon.uf.common.util.AbstractFixture;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Dec 07, 2012 1104 djohnson Initial creation
|
* Dec 07, 2012 1104 djohnson Initial creation
|
||||||
* Feb 07, 2013 1543 djohnson Missing value must be a numeric value.
|
* Feb 07, 2013 1543 djohnson Missing value must be a numeric value.
|
||||||
|
* Feb 13, 2014 2386 bgonzale Added provider name and units.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -67,7 +68,8 @@ public class ParameterFixture extends AbstractFixture<Parameter> {
|
||||||
.get(seedValue)));
|
.get(seedValue)));
|
||||||
obj.setMissingValue("" + seedValue);
|
obj.setMissingValue("" + seedValue);
|
||||||
obj.setName("name" + seedValue);
|
obj.setName("name" + seedValue);
|
||||||
|
obj.setProviderName("ProviderName" + seedValue);
|
||||||
|
obj.setUnits("Units" + seedValue);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,247 +0,0 @@
|
||||||
/**
|
|
||||||
* This software was developed and / or modified by Raytheon Company,
|
|
||||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
|
||||||
*
|
|
||||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
|
||||||
* This software product contains export-restricted data whose
|
|
||||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
|
||||||
* to non-U.S. persons whether in the United States or abroad requires
|
|
||||||
* an export license or other authorization.
|
|
||||||
*
|
|
||||||
* Contractor Name: Raytheon Company
|
|
||||||
* Contractor Address: 6825 Pine Street, Suite 340
|
|
||||||
* Mail Stop B8
|
|
||||||
* Omaha, NE 68106
|
|
||||||
* 402.291.0100
|
|
||||||
*
|
|
||||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
|
||||||
* further licensing information.
|
|
||||||
**/
|
|
||||||
package com.raytheon.uf.common.datadelivery.service.subscription;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
|
||||||
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverage;
|
|
||||||
import com.raytheon.uf.common.datadelivery.registry.GriddedTime;
|
|
||||||
import com.raytheon.uf.common.datadelivery.registry.ParameterFixture;
|
|
||||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
|
|
||||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
|
|
||||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
|
||||||
import com.raytheon.uf.edex.datadelivery.service.services.overlap.GridOverlapData;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GridOverlapData object test class.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
*
|
|
||||||
* SOFTWARE HISTORY
|
|
||||||
*
|
|
||||||
* Date Ticket# Engineer Description
|
|
||||||
* ------------ ---------- ----------- --------------------------
|
|
||||||
* Oct 18, 2013 2292 mpduff Initial creation
|
|
||||||
*
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author mpduff
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class GridOverlapDataTest {
|
|
||||||
private static final GridSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_ALL = new GridSubscriptionOverlapConfig(
|
|
||||||
50, 50, 50, 50, SubscriptionOverlapMatchStrategy.MATCH_ALL);
|
|
||||||
|
|
||||||
private static final GridSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_ANY = new GridSubscriptionOverlapConfig(
|
|
||||||
50, 50, 50, 50, SubscriptionOverlapMatchStrategy.MATCH_ANY);
|
|
||||||
|
|
||||||
private static final GridSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_HALF = new GridSubscriptionOverlapConfig(
|
|
||||||
50, 50, 50, 50, SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Duplicate subs
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchAllWithDuplicates() {
|
|
||||||
SiteSubscription dupeSub1 = getSubscription(1);
|
|
||||||
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
|
|
||||||
dupeSub2.getCoverage().setRequestEnvelope(
|
|
||||||
dupeSub1.getCoverage().getRequestEnvelope());
|
|
||||||
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
|
||||||
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ALL);
|
|
||||||
assertTrue("These should be duplicates", od.isDuplicate());
|
|
||||||
assertTrue("These should overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchAnyWithDuplicates() {
|
|
||||||
SiteSubscription dupeSub1 = getSubscription(1);
|
|
||||||
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
|
|
||||||
dupeSub2.getCoverage().setRequestEnvelope(
|
|
||||||
dupeSub1.getCoverage().getRequestEnvelope());
|
|
||||||
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
|
||||||
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ANY);
|
|
||||||
assertTrue("These should be duplicates", od.isDuplicate());
|
|
||||||
assertTrue("These should overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchHalfWithDuplicates() {
|
|
||||||
SiteSubscription dupeSub1 = getSubscription(1);
|
|
||||||
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
|
|
||||||
dupeSub2.getCoverage().setRequestEnvelope(
|
|
||||||
dupeSub1.getCoverage().getRequestEnvelope());
|
|
||||||
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
|
||||||
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_HALF);
|
|
||||||
assertTrue("These should be duplicates", od.isDuplicate());
|
|
||||||
assertTrue("These should overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Non matching subs
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchAllWithNoMatches() {
|
|
||||||
SiteSubscription sub1 = getSubscription(1);
|
|
||||||
SiteSubscription sub2 = getSubscription(2);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
sub2.getCoverage().setRequestEnvelope(env);
|
|
||||||
sub2.getParameter().clear();
|
|
||||||
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
|
|
||||||
GriddedTime time = new GriddedTime();
|
|
||||||
time.addCycleTime(0);
|
|
||||||
List<Integer> indices = new ArrayList<Integer>(1);
|
|
||||||
indices.add(50);
|
|
||||||
time.setSelectedTimeIndices(indices);
|
|
||||||
sub2.setTime(time);
|
|
||||||
|
|
||||||
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
|
||||||
sub1, sub2, FIFTY_PERCENT_MATCH_ALL);
|
|
||||||
assertFalse("These should not be duplicates", od.isDuplicate());
|
|
||||||
assertFalse("These should not overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchAnyWithNoMatches() {
|
|
||||||
SiteSubscription sub1 = getSubscription(1);
|
|
||||||
SiteSubscription sub2 = getSubscription(2);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
sub2.getCoverage().setRequestEnvelope(env);
|
|
||||||
sub2.getParameter().clear();
|
|
||||||
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
|
|
||||||
GriddedTime time = new GriddedTime();
|
|
||||||
time.addCycleTime(0);
|
|
||||||
List<Integer> indices = new ArrayList<Integer>(1);
|
|
||||||
indices.add(50);
|
|
||||||
time.setSelectedTimeIndices(indices);
|
|
||||||
sub2.setTime(time);
|
|
||||||
|
|
||||||
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
|
||||||
sub1, sub2, FIFTY_PERCENT_MATCH_ANY);
|
|
||||||
assertFalse("These should not be duplicates", od.isDuplicate());
|
|
||||||
assertFalse("These should not overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchHalfWithNoMatches() {
|
|
||||||
SiteSubscription sub1 = getSubscription(1);
|
|
||||||
SiteSubscription sub2 = getSubscription(2);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
sub2.getCoverage().setRequestEnvelope(env);
|
|
||||||
sub2.getParameter().clear();
|
|
||||||
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
|
|
||||||
GriddedTime time = new GriddedTime();
|
|
||||||
time.addCycleTime(0);
|
|
||||||
List<Integer> indices = new ArrayList<Integer>(1);
|
|
||||||
indices.add(50);
|
|
||||||
time.setSelectedTimeIndices(indices);
|
|
||||||
sub2.setTime(time);
|
|
||||||
|
|
||||||
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
|
||||||
sub1, sub2, FIFTY_PERCENT_MATCH_HALF);
|
|
||||||
assertFalse("These should not be duplicates", od.isDuplicate());
|
|
||||||
assertFalse("These should not overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Half matching subs - match parameter and cycle times
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchAllWithHalfMatches() {
|
|
||||||
SiteSubscription sub1 = getSubscription(1);
|
|
||||||
SiteSubscription sub2 = getSubscription(2);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
sub2.getCoverage().setRequestEnvelope(env);
|
|
||||||
GriddedTime time = new GriddedTime((GriddedTime) sub1.getTime());
|
|
||||||
List<Integer> indices = new ArrayList<Integer>(1);
|
|
||||||
indices.add(50);
|
|
||||||
time.setSelectedTimeIndices(indices);
|
|
||||||
sub2.setTime(time);
|
|
||||||
|
|
||||||
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
|
||||||
sub1, sub2, FIFTY_PERCENT_MATCH_ALL);
|
|
||||||
assertFalse("These should not be duplicates", od.isDuplicate());
|
|
||||||
assertFalse("These should not overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchAnyWithHalfMatches() {
|
|
||||||
SiteSubscription sub1 = getSubscription(1);
|
|
||||||
SiteSubscription sub2 = getSubscription(2);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
sub2.getCoverage().setRequestEnvelope(env);
|
|
||||||
GriddedTime time = new GriddedTime((GriddedTime) sub1.getTime());
|
|
||||||
List<Integer> indices = new ArrayList<Integer>(1);
|
|
||||||
indices.add(50);
|
|
||||||
time.setSelectedTimeIndices(indices);
|
|
||||||
sub2.setTime(time);
|
|
||||||
|
|
||||||
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
|
||||||
sub1, sub2, FIFTY_PERCENT_MATCH_ANY);
|
|
||||||
assertFalse("These should not be duplicates", od.isDuplicate());
|
|
||||||
assertTrue("These should not overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchHalfWithHalfMatches() {
|
|
||||||
SiteSubscription sub1 = getSubscription(1);
|
|
||||||
SiteSubscription sub2 = getSubscription(2);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
sub2.getCoverage().setRequestEnvelope(env);
|
|
||||||
GriddedTime time = new GriddedTime((GriddedTime) sub1.getTime());
|
|
||||||
List<Integer> indices = new ArrayList<Integer>(1);
|
|
||||||
indices.add(50);
|
|
||||||
time.setSelectedTimeIndices(indices);
|
|
||||||
sub2.setTime(time);
|
|
||||||
|
|
||||||
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
|
||||||
sub1, sub2, FIFTY_PERCENT_MATCH_HALF);
|
|
||||||
assertFalse("These should not be duplicates", od.isDuplicate());
|
|
||||||
assertTrue("These should overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
private SiteSubscription getSubscription(int seed) {
|
|
||||||
SiteSubscription sub = SiteSubscriptionFixture.INSTANCE.get(seed,
|
|
||||||
DataType.GRID);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(0, 15, 0, 15,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
|
|
||||||
sub.getCoverage().setRequestEnvelope(env);
|
|
||||||
return sub;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,202 +0,0 @@
|
||||||
package com.raytheon.uf.common.datadelivery.service.subscription;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import com.raytheon.uf.common.datadelivery.registry.Coverage;
|
|
||||||
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
|
||||||
import com.raytheon.uf.common.datadelivery.registry.ParameterFixture;
|
|
||||||
import com.raytheon.uf.common.datadelivery.registry.PointTime;
|
|
||||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
|
|
||||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
|
|
||||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
|
||||||
import com.raytheon.uf.edex.datadelivery.service.services.overlap.PointOverlapData;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PointOverlapData object test class.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
*
|
|
||||||
* SOFTWARE HISTORY
|
|
||||||
*
|
|
||||||
* Date Ticket# Engineer Description
|
|
||||||
* ------------ ---------- ----------- --------------------------
|
|
||||||
* Oct 18, 2013 2292 mpduff Initial creation
|
|
||||||
*
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author mpduff
|
|
||||||
* @version 1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class PointOverlapDataTest {
|
|
||||||
private static final PointSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_ALL = new PointSubscriptionOverlapConfig(
|
|
||||||
50, 50, 50, SubscriptionOverlapMatchStrategy.MATCH_ALL);
|
|
||||||
|
|
||||||
private static final PointSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_ANY = new PointSubscriptionOverlapConfig(
|
|
||||||
50, 50, 50, SubscriptionOverlapMatchStrategy.MATCH_ANY);
|
|
||||||
|
|
||||||
private static final PointSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_HALF = new PointSubscriptionOverlapConfig(
|
|
||||||
50, 50, 50, SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Duplicate subs
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchAllWithDuplicates() {
|
|
||||||
SiteSubscription dupeSub1 = getSubscription(1);
|
|
||||||
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
|
|
||||||
dupeSub2.getCoverage().setRequestEnvelope(
|
|
||||||
dupeSub1.getCoverage().getRequestEnvelope());
|
|
||||||
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
|
||||||
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ALL);
|
|
||||||
assertTrue("These should be duplicates", od.isDuplicate());
|
|
||||||
assertTrue("These should overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchAnyWithDuplicates() {
|
|
||||||
SiteSubscription dupeSub1 = getSubscription(1);
|
|
||||||
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
|
|
||||||
dupeSub2.getCoverage().setRequestEnvelope(
|
|
||||||
dupeSub1.getCoverage().getRequestEnvelope());
|
|
||||||
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
|
||||||
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ALL);
|
|
||||||
assertTrue("These should be duplicates", od.isDuplicate());
|
|
||||||
assertTrue("These should overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchHalfWithDuplicates() {
|
|
||||||
SiteSubscription dupeSub1 = getSubscription(1);
|
|
||||||
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
|
|
||||||
dupeSub2.getCoverage().setRequestEnvelope(
|
|
||||||
dupeSub1.getCoverage().getRequestEnvelope());
|
|
||||||
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
|
||||||
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ALL);
|
|
||||||
assertTrue("These should be duplicates", od.isDuplicate());
|
|
||||||
assertTrue("These should overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Non matching subs
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchAllWithNoMatches() {
|
|
||||||
SiteSubscription sub1 = getSubscription(1);
|
|
||||||
SiteSubscription sub2 = getSubscription(2);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
sub2.getCoverage().setRequestEnvelope(env);
|
|
||||||
sub2.getParameter().clear();
|
|
||||||
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
|
|
||||||
PointTime time = new PointTime();
|
|
||||||
time.setInterval(100);
|
|
||||||
sub2.setTime(time);
|
|
||||||
|
|
||||||
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
|
||||||
sub1, sub2, FIFTY_PERCENT_MATCH_ALL);
|
|
||||||
assertFalse("These should not be duplicates", od.isDuplicate());
|
|
||||||
assertFalse("These should not overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchAnyWithNoMatches() {
|
|
||||||
SiteSubscription sub1 = getSubscription(1);
|
|
||||||
SiteSubscription sub2 = getSubscription(2);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
sub2.getCoverage().setRequestEnvelope(env);
|
|
||||||
sub2.getParameter().clear();
|
|
||||||
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
|
|
||||||
PointTime time = new PointTime();
|
|
||||||
time.setInterval(100);
|
|
||||||
sub2.setTime(time);
|
|
||||||
|
|
||||||
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
|
||||||
sub1, sub2, FIFTY_PERCENT_MATCH_ANY);
|
|
||||||
assertFalse("These should not be duplicates", od.isDuplicate());
|
|
||||||
assertFalse("These should not overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchHalfWithNoMatches() {
|
|
||||||
SiteSubscription sub1 = getSubscription(1);
|
|
||||||
SiteSubscription sub2 = getSubscription(2);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
sub2.getCoverage().setRequestEnvelope(env);
|
|
||||||
sub2.getParameter().clear();
|
|
||||||
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
|
|
||||||
PointTime time = new PointTime();
|
|
||||||
time.setInterval(100);
|
|
||||||
sub2.setTime(time);
|
|
||||||
|
|
||||||
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
|
||||||
sub1, sub2, FIFTY_PERCENT_MATCH_HALF);
|
|
||||||
assertFalse("These should not be duplicates", od.isDuplicate());
|
|
||||||
assertFalse("These should not overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Half matching subs - match parameter and interval
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchAllWithHalfMatches() {
|
|
||||||
SiteSubscription sub1 = getSubscription(1);
|
|
||||||
SiteSubscription sub2 = getSubscription(2);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
sub2.getCoverage().setRequestEnvelope(env);
|
|
||||||
|
|
||||||
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
|
||||||
sub1, sub2, FIFTY_PERCENT_MATCH_ALL);
|
|
||||||
assertFalse("These should not be duplicates", od.isDuplicate());
|
|
||||||
assertFalse("These should not overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchAnyWithHalfMatches() {
|
|
||||||
SiteSubscription sub1 = getSubscription(1);
|
|
||||||
SiteSubscription sub2 = getSubscription(2);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
sub2.getCoverage().setRequestEnvelope(env);
|
|
||||||
|
|
||||||
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
|
||||||
sub1, sub2, FIFTY_PERCENT_MATCH_ANY);
|
|
||||||
assertFalse("These should not be duplicates", od.isDuplicate());
|
|
||||||
assertTrue("These should not overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFiftyPercentMatchHalfWithHalfMatches() {
|
|
||||||
SiteSubscription sub1 = getSubscription(1);
|
|
||||||
SiteSubscription sub2 = getSubscription(2);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
sub2.getCoverage().setRequestEnvelope(env);
|
|
||||||
|
|
||||||
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
|
||||||
sub1, sub2, FIFTY_PERCENT_MATCH_HALF);
|
|
||||||
assertFalse("These should not be duplicates", od.isDuplicate());
|
|
||||||
assertTrue("These should overlap", od.isOverlapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
private SiteSubscription getSubscription(int seed) {
|
|
||||||
SiteSubscription sub = SiteSubscriptionFixture.INSTANCE.get(seed,
|
|
||||||
DataType.POINT);
|
|
||||||
ReferencedEnvelope env = new ReferencedEnvelope(0, 15, 0, 15,
|
|
||||||
MapUtil.LATLON_PROJECTION);
|
|
||||||
|
|
||||||
sub.getCoverage().setRequestEnvelope(env);
|
|
||||||
return sub;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,716 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.edex.datadelivery.service.services.overlap;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.GriddedCoverage;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.GriddedTime;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.GriddedTimeFixture;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.Parameter;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.ParameterFixture;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.Time;
|
||||||
|
import com.raytheon.uf.common.datadelivery.service.subscription.GridSubscriptionOverlapConfig;
|
||||||
|
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy;
|
||||||
|
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||||
|
import com.vividsolutions.jts.geom.Envelope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GridOverlapData object test class.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Oct 18, 2013 2292 mpduff Initial creation
|
||||||
|
* Feb 13, 2014 2386 bgonzale Added test cases to match ticket 2771 test procedures.
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author mpduff
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GridOverlapDataTest {
|
||||||
|
private static final GridSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_ALL = new GridSubscriptionOverlapConfig(
|
||||||
|
50, 50, 50, 50, SubscriptionOverlapMatchStrategy.MATCH_ALL);
|
||||||
|
|
||||||
|
private static final GridSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_ANY = new GridSubscriptionOverlapConfig(
|
||||||
|
50, 50, 50, 50, SubscriptionOverlapMatchStrategy.MATCH_ANY);
|
||||||
|
|
||||||
|
private static final GridSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_HALF = new GridSubscriptionOverlapConfig(
|
||||||
|
50, 50, 50, 50, SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
||||||
|
|
||||||
|
private static ArrayList<Parameter> matchMeParameters;
|
||||||
|
|
||||||
|
private static SiteSubscription matchMe;
|
||||||
|
|
||||||
|
private static Envelope areaMatchMe;
|
||||||
|
|
||||||
|
private static Envelope areaLessThan50PercentOverlap;
|
||||||
|
|
||||||
|
private static Envelope areaGreaterThan50PercentOverlap;
|
||||||
|
|
||||||
|
private static Envelope areaWithNoOverlap;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setup() {
|
||||||
|
matchMeParameters = new ArrayList<Parameter>();
|
||||||
|
matchMeParameters.add(ParameterFixture.INSTANCE.get(1));
|
||||||
|
|
||||||
|
areaMatchMe = new Envelope(0, 10, 0, 20);
|
||||||
|
areaLessThan50PercentOverlap = new Envelope(0, 25, 0, 15);
|
||||||
|
areaGreaterThan50PercentOverlap = new Envelope(0, 10, 10, 25);
|
||||||
|
areaWithNoOverlap = new Envelope(0, 30, 20, 20);
|
||||||
|
|
||||||
|
matchMe = getSubscription(
|
||||||
|
1,
|
||||||
|
areaMatchMe,
|
||||||
|
matchMeParameters,
|
||||||
|
createGriddedTime(Arrays.asList(0, 1, 2, 3),
|
||||||
|
Arrays.asList(0, 1, 2, 3)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Duplicate subs
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchAllWithDuplicates() {
|
||||||
|
SiteSubscription dupeSub1 = getSubscription(1);
|
||||||
|
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
|
||||||
|
dupeSub2.getCoverage().setRequestEnvelope(
|
||||||
|
dupeSub1.getCoverage().getRequestEnvelope());
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ALL);
|
||||||
|
assertTrue("These should be duplicates", od.isDuplicate());
|
||||||
|
assertTrue("These should overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchAnyWithDuplicates() {
|
||||||
|
SiteSubscription dupeSub1 = getSubscription(1);
|
||||||
|
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
|
||||||
|
dupeSub2.getCoverage().setRequestEnvelope(
|
||||||
|
dupeSub1.getCoverage().getRequestEnvelope());
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ANY);
|
||||||
|
assertTrue("These should be duplicates", od.isDuplicate());
|
||||||
|
assertTrue("These should overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchHalfWithDuplicates() {
|
||||||
|
SiteSubscription dupeSub1 = getSubscription(1);
|
||||||
|
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
|
||||||
|
dupeSub2.getCoverage().setRequestEnvelope(
|
||||||
|
dupeSub1.getCoverage().getRequestEnvelope());
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_HALF);
|
||||||
|
assertTrue("These should be duplicates", od.isDuplicate());
|
||||||
|
assertTrue("These should overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Non matching subs
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchAllWithNoMatches() {
|
||||||
|
SiteSubscription sub1 = getSubscription(1);
|
||||||
|
SiteSubscription sub2 = getSubscription(2);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
sub2.getCoverage().setRequestEnvelope(env);
|
||||||
|
sub2.getParameter().clear();
|
||||||
|
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
|
||||||
|
GriddedTime time = new GriddedTime();
|
||||||
|
time.addCycleTime(0);
|
||||||
|
List<Integer> indices = new ArrayList<Integer>(1);
|
||||||
|
indices.add(50);
|
||||||
|
time.setSelectedTimeIndices(indices);
|
||||||
|
sub2.setTime(time);
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
sub1, sub2, FIFTY_PERCENT_MATCH_ALL);
|
||||||
|
assertFalse("These should not be duplicates", od.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchAnyWithNoMatches() {
|
||||||
|
SiteSubscription sub1 = getSubscription(1);
|
||||||
|
SiteSubscription sub2 = getSubscription(2);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
sub2.getCoverage().setRequestEnvelope(env);
|
||||||
|
sub2.getParameter().clear();
|
||||||
|
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
|
||||||
|
GriddedTime time = new GriddedTime();
|
||||||
|
time.addCycleTime(0);
|
||||||
|
List<Integer> indices = new ArrayList<Integer>(1);
|
||||||
|
indices.add(50);
|
||||||
|
time.setSelectedTimeIndices(indices);
|
||||||
|
sub2.setTime(time);
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
sub1, sub2, FIFTY_PERCENT_MATCH_ANY);
|
||||||
|
assertFalse("These should not be duplicates", od.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchHalfWithNoMatches() {
|
||||||
|
SiteSubscription sub1 = getSubscription(1);
|
||||||
|
SiteSubscription sub2 = getSubscription(2);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
sub2.getCoverage().setRequestEnvelope(env);
|
||||||
|
sub2.getParameter().clear();
|
||||||
|
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
|
||||||
|
GriddedTime time = new GriddedTime();
|
||||||
|
time.addCycleTime(0);
|
||||||
|
List<Integer> indices = new ArrayList<Integer>(1);
|
||||||
|
indices.add(50);
|
||||||
|
time.setSelectedTimeIndices(indices);
|
||||||
|
sub2.setTime(time);
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
sub1, sub2, FIFTY_PERCENT_MATCH_HALF);
|
||||||
|
assertFalse("These should not be duplicates", od.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Half matching subs - match parameter and cycle times
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchAllWithHalfMatches() {
|
||||||
|
SiteSubscription sub1 = getSubscription(1);
|
||||||
|
SiteSubscription sub2 = getSubscription(2);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
sub2.getCoverage().setRequestEnvelope(env);
|
||||||
|
GriddedTime time = new GriddedTime((GriddedTime) sub1.getTime());
|
||||||
|
List<Integer> indices = new ArrayList<Integer>(1);
|
||||||
|
indices.add(50);
|
||||||
|
time.setSelectedTimeIndices(indices);
|
||||||
|
sub2.setTime(time);
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
sub1, sub2, FIFTY_PERCENT_MATCH_ALL);
|
||||||
|
assertFalse("These should not be duplicates", od.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchAnyWithHalfMatches() {
|
||||||
|
SiteSubscription sub1 = getSubscription(1);
|
||||||
|
SiteSubscription sub2 = getSubscription(2);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
sub2.getCoverage().setRequestEnvelope(env);
|
||||||
|
GriddedTime time = new GriddedTime((GriddedTime) sub1.getTime());
|
||||||
|
List<Integer> indices = new ArrayList<Integer>(1);
|
||||||
|
indices.add(50);
|
||||||
|
time.setSelectedTimeIndices(indices);
|
||||||
|
sub2.setTime(time);
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
sub1, sub2, FIFTY_PERCENT_MATCH_ANY);
|
||||||
|
assertFalse("These should not be duplicates", od.isDuplicate());
|
||||||
|
assertTrue("These should not overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchHalfWithHalfMatches() {
|
||||||
|
SiteSubscription sub1 = getSubscription(1);
|
||||||
|
SiteSubscription sub2 = getSubscription(2);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
sub2.getCoverage().setRequestEnvelope(env);
|
||||||
|
GriddedTime time = new GriddedTime((GriddedTime) sub1.getTime());
|
||||||
|
List<Integer> indices = new ArrayList<Integer>(1);
|
||||||
|
indices.add(50);
|
||||||
|
time.setSelectedTimeIndices(indices);
|
||||||
|
sub2.setTime(time);
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> od = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
sub1, sub2, FIFTY_PERCENT_MATCH_HALF);
|
||||||
|
assertFalse("These should not be duplicates", od.isDuplicate());
|
||||||
|
assertTrue("These should overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAllNotEnoughSpatialOverlap() {
|
||||||
|
int parameter = 100;
|
||||||
|
int spatial = 50;
|
||||||
|
int forecastHours = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final GridSubscriptionOverlapConfig overlap = new GridSubscriptionOverlapConfig(
|
||||||
|
parameter, forecastHours, cycles, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.MATCH_ALL);
|
||||||
|
List<Parameter> parameters = new ArrayList<Parameter>();
|
||||||
|
parameters.add(ParameterFixture.INSTANCE.get(1));
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(
|
||||||
|
1,
|
||||||
|
areaLessThan50PercentOverlap,
|
||||||
|
parameters,
|
||||||
|
createGriddedTime(Arrays.asList(0, 1, 2, 3),
|
||||||
|
Arrays.asList(0, 1, 2, 3)));
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> overlapResult = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
matchMe, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", overlapResult.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAllSpatialOverlap() {
|
||||||
|
int parameter = 100;
|
||||||
|
int spatial = 50;
|
||||||
|
int forecastHours = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final GridSubscriptionOverlapConfig overlap = new GridSubscriptionOverlapConfig(
|
||||||
|
parameter, forecastHours, cycles, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.MATCH_ALL);
|
||||||
|
SiteSubscription sub3 = getSubscription(
|
||||||
|
1,
|
||||||
|
areaGreaterThan50PercentOverlap,
|
||||||
|
matchMeParameters,
|
||||||
|
createGriddedTime(Arrays.asList(0, 1, 2, 3),
|
||||||
|
Arrays.asList(0, 1, 2, 3)));
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> overlapResult = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
matchMe, sub3, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAnyParametersOnly() {
|
||||||
|
int parameter = 50;
|
||||||
|
int spatial = 50;
|
||||||
|
int forecastHours = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final GridSubscriptionOverlapConfig overlap = new GridSubscriptionOverlapConfig(
|
||||||
|
parameter, forecastHours, cycles, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.MATCH_ANY);
|
||||||
|
|
||||||
|
List<Parameter> parameters2 = new ArrayList<Parameter>();
|
||||||
|
parameters2.addAll(matchMeParameters);
|
||||||
|
parameters2.add(ParameterFixture.INSTANCE.get(20));
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(
|
||||||
|
1,
|
||||||
|
areaWithNoOverlap,
|
||||||
|
parameters2,
|
||||||
|
createGriddedTime(Arrays.asList(4, 5, 6),
|
||||||
|
Arrays.asList(4, 5, 6)));
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> overlapResult = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
matchMe, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
assertFalse("These should not overlap", overlapResult.cyclePass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.fcstHrPass);
|
||||||
|
assertTrue("These should overlap", overlapResult.parameterPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAnySpatialOnly() {
|
||||||
|
int parameter = 50;
|
||||||
|
int spatial = 50;
|
||||||
|
int forecastHours = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final GridSubscriptionOverlapConfig overlap = new GridSubscriptionOverlapConfig(
|
||||||
|
parameter, forecastHours, cycles, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.MATCH_ANY);
|
||||||
|
|
||||||
|
List<Parameter> parameters2 = new ArrayList<Parameter>();
|
||||||
|
parameters2.addAll(matchMeParameters);
|
||||||
|
parameters2.add(ParameterFixture.INSTANCE.get(20));
|
||||||
|
|
||||||
|
List<Parameter> parameters3 = new ArrayList<Parameter>();
|
||||||
|
parameters3.add(ParameterFixture.INSTANCE.get(30));
|
||||||
|
|
||||||
|
SiteSubscription sub3 = getSubscription(
|
||||||
|
1,
|
||||||
|
areaGreaterThan50PercentOverlap,
|
||||||
|
parameters3,
|
||||||
|
createGriddedTime(Arrays.asList(7, 8, 9),
|
||||||
|
Arrays.asList(7, 8, 9)));
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> overlapResult = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
matchMe, sub3, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
assertFalse("These should not overlap", overlapResult.cyclePass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.fcstHrPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.parameterPass);
|
||||||
|
assertTrue("These should overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAnyForecastHoursOnly() {
|
||||||
|
int parameter = 50;
|
||||||
|
int spatial = 50;
|
||||||
|
int forecastHours = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final GridSubscriptionOverlapConfig overlap = new GridSubscriptionOverlapConfig(
|
||||||
|
parameter, forecastHours, cycles, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.MATCH_ANY);
|
||||||
|
|
||||||
|
List<Parameter> parameters2 = new ArrayList<Parameter>();
|
||||||
|
parameters2.add(ParameterFixture.INSTANCE.get(20));
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(
|
||||||
|
1,
|
||||||
|
areaWithNoOverlap,
|
||||||
|
parameters2,
|
||||||
|
createGriddedTime(Arrays.asList(0, 1, 2, 3),
|
||||||
|
Arrays.asList(10, 11, 12)));
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> overlapResult = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
matchMe, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
assertFalse("These should not overlap", overlapResult.cyclePass);
|
||||||
|
assertTrue("These should overlap", overlapResult.fcstHrPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.parameterPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAnyCyclesOnly() {
|
||||||
|
int parameter = 50;
|
||||||
|
int spatial = 50;
|
||||||
|
int forecastHours = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final GridSubscriptionOverlapConfig overlap = new GridSubscriptionOverlapConfig(
|
||||||
|
parameter, forecastHours, cycles, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.MATCH_ANY);
|
||||||
|
|
||||||
|
List<Parameter> parameters2 = new ArrayList<Parameter>();
|
||||||
|
parameters2.add(ParameterFixture.INSTANCE.get(20));
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(
|
||||||
|
1,
|
||||||
|
areaWithNoOverlap,
|
||||||
|
parameters2,
|
||||||
|
createGriddedTime(Arrays.asList(10, 11, 12),
|
||||||
|
Arrays.asList(0, 1, 2, 3)));
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> overlapResult = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
matchMe, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
assertTrue("These should overlap", overlapResult.cyclePass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.fcstHrPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.parameterPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAnyNoMatches() {
|
||||||
|
int parameter = 50;
|
||||||
|
int spatial = 50;
|
||||||
|
int forecastHours = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final GridSubscriptionOverlapConfig overlap = new GridSubscriptionOverlapConfig(
|
||||||
|
parameter, forecastHours, cycles, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.MATCH_ANY);
|
||||||
|
|
||||||
|
List<Parameter> parameters2 = new ArrayList<Parameter>();
|
||||||
|
parameters2.add(ParameterFixture.INSTANCE.get(20));
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(
|
||||||
|
1,
|
||||||
|
areaWithNoOverlap,
|
||||||
|
parameters2,
|
||||||
|
createGriddedTime(Arrays.asList(13, 14, 15),
|
||||||
|
Arrays.asList(13, 14, 15)));
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> overlapResult = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
matchMe, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", overlapResult.isOverlapping());
|
||||||
|
assertFalse("These should not overlap", overlapResult.cyclePass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.fcstHrPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.parameterPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAtLeastHalfParametersAndSpatial() {
|
||||||
|
int parameter = 50;
|
||||||
|
int spatial = 50;
|
||||||
|
int forecastHours = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final GridSubscriptionOverlapConfig overlap = new GridSubscriptionOverlapConfig(
|
||||||
|
parameter, forecastHours, cycles, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
||||||
|
|
||||||
|
List<Parameter> parameters2 = new ArrayList<Parameter>();
|
||||||
|
parameters2.addAll(matchMeParameters);
|
||||||
|
parameters2.add(ParameterFixture.INSTANCE.get(20));
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(
|
||||||
|
1,
|
||||||
|
areaMatchMe,
|
||||||
|
parameters2,
|
||||||
|
createGriddedTime(Arrays.asList(4, 5, 6),
|
||||||
|
Arrays.asList(4, 5, 6)));
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> overlapResult = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
matchMe, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
assertFalse("These should not overlap", overlapResult.cyclePass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.fcstHrPass);
|
||||||
|
assertTrue("These should overlap", overlapResult.parameterPass);
|
||||||
|
assertTrue("These should overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAtLeastHalfForecastHoursCycles() {
|
||||||
|
int parameter = 50;
|
||||||
|
int spatial = 50;
|
||||||
|
int forecastHours = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final GridSubscriptionOverlapConfig overlap = new GridSubscriptionOverlapConfig(
|
||||||
|
parameter, forecastHours, cycles, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
||||||
|
|
||||||
|
List<Parameter> parameters2 = new ArrayList<Parameter>();
|
||||||
|
parameters2.add(ParameterFixture.INSTANCE.get(20));
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(
|
||||||
|
1,
|
||||||
|
areaWithNoOverlap,
|
||||||
|
parameters2,
|
||||||
|
createGriddedTime(Arrays.asList(0, 1, 2, 3),
|
||||||
|
Arrays.asList(0, 1, 2, 3)));
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> overlapResult = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
matchMe, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
assertTrue("These should overlap", overlapResult.cyclePass);
|
||||||
|
assertTrue("These should overlap", overlapResult.fcstHrPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.parameterPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAtLeastHalfParametersForecastHours() {
|
||||||
|
int parameter = 50;
|
||||||
|
int spatial = 50;
|
||||||
|
int forecastHours = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final GridSubscriptionOverlapConfig overlap = new GridSubscriptionOverlapConfig(
|
||||||
|
parameter, forecastHours, cycles, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
||||||
|
|
||||||
|
List<Parameter> parameters2 = new ArrayList<Parameter>();
|
||||||
|
parameters2.addAll(matchMeParameters);
|
||||||
|
parameters2.add(ParameterFixture.INSTANCE.get(20));
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(
|
||||||
|
1,
|
||||||
|
areaWithNoOverlap,
|
||||||
|
parameters2,
|
||||||
|
createGriddedTime(Arrays.asList(0, 1, 2, 3),
|
||||||
|
Arrays.asList(7, 8, 9)));
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> overlapResult = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
matchMe, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
assertFalse("These should not overlap", overlapResult.cyclePass);
|
||||||
|
assertTrue("These should overlap", overlapResult.fcstHrPass);
|
||||||
|
assertTrue("These should overlap", overlapResult.parameterPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAtLeastHalfSpatialAndCycles() {
|
||||||
|
int parameter = 50;
|
||||||
|
int spatial = 50;
|
||||||
|
int forecastHours = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final GridSubscriptionOverlapConfig overlap = new GridSubscriptionOverlapConfig(
|
||||||
|
parameter, forecastHours, cycles, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
||||||
|
|
||||||
|
List<Parameter> parameters2 = new ArrayList<Parameter>();
|
||||||
|
parameters2.add(ParameterFixture.INSTANCE.get(20));
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(
|
||||||
|
1,
|
||||||
|
areaMatchMe,
|
||||||
|
parameters2,
|
||||||
|
createGriddedTime(Arrays.asList(10, 11, 12),
|
||||||
|
Arrays.asList(0, 1, 2, 3)));
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> overlapResult = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
matchMe, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
assertTrue("These should overlap", overlapResult.cyclePass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.fcstHrPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.parameterPass);
|
||||||
|
assertTrue("These should overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAtLeastHalfOneMatch() {
|
||||||
|
int parameter = 50;
|
||||||
|
int spatial = 50;
|
||||||
|
int forecastHours = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final GridSubscriptionOverlapConfig overlap = new GridSubscriptionOverlapConfig(
|
||||||
|
parameter, forecastHours, cycles, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
||||||
|
|
||||||
|
List<Parameter> parameters2 = new ArrayList<Parameter>();
|
||||||
|
parameters2.addAll(matchMeParameters);
|
||||||
|
parameters2.add(ParameterFixture.INSTANCE.get(20));
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(
|
||||||
|
1,
|
||||||
|
areaWithNoOverlap,
|
||||||
|
parameters2,
|
||||||
|
createGriddedTime(Arrays.asList(13, 14, 15),
|
||||||
|
Arrays.asList(13, 14, 15)));
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> overlapResult = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
matchMe, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", overlapResult.isOverlapping());
|
||||||
|
assertFalse("These should not overlap", overlapResult.cyclePass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.fcstHrPass);
|
||||||
|
assertTrue("These should overlap", overlapResult.parameterPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAtLeastHalfNoMatches() {
|
||||||
|
int parameter = 50;
|
||||||
|
int spatial = 50;
|
||||||
|
int forecastHours = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final GridSubscriptionOverlapConfig overlap = new GridSubscriptionOverlapConfig(
|
||||||
|
parameter, forecastHours, cycles, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
||||||
|
|
||||||
|
List<Parameter> parameters1 = new ArrayList<Parameter>();
|
||||||
|
parameters1.add(ParameterFixture.INSTANCE.get(10));
|
||||||
|
|
||||||
|
List<Parameter> parameters2 = new ArrayList<Parameter>();
|
||||||
|
parameters2.add(ParameterFixture.INSTANCE.get(20));
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(
|
||||||
|
1,
|
||||||
|
areaWithNoOverlap,
|
||||||
|
parameters2,
|
||||||
|
createGriddedTime(Arrays.asList(16, 17, 18),
|
||||||
|
Arrays.asList(16, 17, 18)));
|
||||||
|
|
||||||
|
GridOverlapData<GriddedTime, GriddedCoverage> overlapResult = new GridOverlapData<GriddedTime, GriddedCoverage>(
|
||||||
|
matchMe, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", overlapResult.isOverlapping());
|
||||||
|
assertFalse("These should not overlap", overlapResult.cyclePass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.fcstHrPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.parameterPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Time createGriddedTime(List<Integer> selectedTimeIndices,
|
||||||
|
List<Integer> cycleTimes) {
|
||||||
|
GriddedTime time = GriddedTimeFixture.INSTANCE.get();
|
||||||
|
time.setCycleTimes(cycleTimes);
|
||||||
|
time.setSelectedTimeIndices(selectedTimeIndices);
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SiteSubscription getSubscription(int seed) {
|
||||||
|
List<Parameter> parameters = new ArrayList<Parameter>();
|
||||||
|
parameters.add(ParameterFixture.INSTANCE.get());
|
||||||
|
return getSubscription(seed, 0, 0, 15, 15, parameters,
|
||||||
|
GriddedTimeFixture.INSTANCE.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SiteSubscription getSubscription(int seed, double x1,
|
||||||
|
double y1, double x2, int y2, List<Parameter> parameters, Time time) {
|
||||||
|
SiteSubscription sub = SiteSubscriptionFixture.INSTANCE.get(seed,
|
||||||
|
DataType.GRID);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(x1, x2, y1, y2,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
|
||||||
|
sub.getCoverage().setRequestEnvelope(env);
|
||||||
|
sub.setParameter(parameters);
|
||||||
|
sub.setTime(time);
|
||||||
|
return sub;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SiteSubscription getSubscription(int seed,
|
||||||
|
Envelope envelope, List<Parameter> parameters, Time time) {
|
||||||
|
SiteSubscription sub = SiteSubscriptionFixture.INSTANCE.get(seed,
|
||||||
|
DataType.GRID);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(envelope,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
|
||||||
|
sub.getCoverage().setRequestEnvelope(env);
|
||||||
|
sub.setParameter(parameters);
|
||||||
|
sub.setTime(time);
|
||||||
|
return sub;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,407 @@
|
||||||
|
package com.raytheon.uf.edex.datadelivery.service.services.overlap;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.Coverage;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.Parameter;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.ParameterFixture;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.PointTime;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.PointTimeFixture;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.SiteSubscriptionFixture;
|
||||||
|
import com.raytheon.uf.common.datadelivery.registry.Time;
|
||||||
|
import com.raytheon.uf.common.datadelivery.service.subscription.PointSubscriptionOverlapConfig;
|
||||||
|
import com.raytheon.uf.common.datadelivery.service.subscription.SubscriptionOverlapMatchStrategy;
|
||||||
|
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||||
|
import com.vividsolutions.jts.geom.Envelope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PointOverlapData object test class.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Oct 18, 2013 2292 mpduff Initial creation
|
||||||
|
* Feb 13, 2014 2386 bgonzale Added test cases to match ticket 2771 test procedures.
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author mpduff
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class PointOverlapDataTest {
|
||||||
|
private static final PointSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_ALL = new PointSubscriptionOverlapConfig(
|
||||||
|
50, 50, 50, SubscriptionOverlapMatchStrategy.MATCH_ALL);
|
||||||
|
|
||||||
|
private static final PointSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_ANY = new PointSubscriptionOverlapConfig(
|
||||||
|
50, 50, 50, SubscriptionOverlapMatchStrategy.MATCH_ANY);
|
||||||
|
|
||||||
|
private static final PointSubscriptionOverlapConfig FIFTY_PERCENT_MATCH_HALF = new PointSubscriptionOverlapConfig(
|
||||||
|
50, 50, 50, SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
||||||
|
|
||||||
|
private static SiteSubscription matchPoints;
|
||||||
|
|
||||||
|
private static Envelope areaMatchPoints;
|
||||||
|
|
||||||
|
private static Envelope areaLessThan50PercentOverlap;
|
||||||
|
|
||||||
|
private static Envelope areaGreaterThan50PercentOverlap;
|
||||||
|
|
||||||
|
private static Envelope areaWithNoOverlap;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setup() {
|
||||||
|
areaMatchPoints = new Envelope(0, 10, 0, 20);
|
||||||
|
areaLessThan50PercentOverlap = new Envelope(0, 25, 0, 15);
|
||||||
|
areaGreaterThan50PercentOverlap = new Envelope(0, 10, 10, 25);
|
||||||
|
areaWithNoOverlap = new Envelope(0, 30, 20, 20);
|
||||||
|
|
||||||
|
matchPoints = getSubscription(1, areaMatchPoints, createPointTime(30));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Duplicate subs
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchAllWithDuplicates() {
|
||||||
|
SiteSubscription dupeSub1 = getSubscription(1);
|
||||||
|
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
|
||||||
|
dupeSub2.getCoverage().setRequestEnvelope(
|
||||||
|
dupeSub1.getCoverage().getRequestEnvelope());
|
||||||
|
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ALL);
|
||||||
|
assertTrue("These should be duplicates", od.isDuplicate());
|
||||||
|
assertTrue("These should overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchAnyWithDuplicates() {
|
||||||
|
SiteSubscription dupeSub1 = getSubscription(1);
|
||||||
|
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
|
||||||
|
dupeSub2.getCoverage().setRequestEnvelope(
|
||||||
|
dupeSub1.getCoverage().getRequestEnvelope());
|
||||||
|
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ALL);
|
||||||
|
assertTrue("These should be duplicates", od.isDuplicate());
|
||||||
|
assertTrue("These should overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchHalfWithDuplicates() {
|
||||||
|
SiteSubscription dupeSub1 = getSubscription(1);
|
||||||
|
SiteSubscription dupeSub2 = new SiteSubscription(dupeSub1);
|
||||||
|
dupeSub2.getCoverage().setRequestEnvelope(
|
||||||
|
dupeSub1.getCoverage().getRequestEnvelope());
|
||||||
|
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
dupeSub1, dupeSub2, FIFTY_PERCENT_MATCH_ALL);
|
||||||
|
assertTrue("These should be duplicates", od.isDuplicate());
|
||||||
|
assertTrue("These should overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Non matching subs
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchAllWithNoMatches() {
|
||||||
|
SiteSubscription sub1 = getSubscription(1);
|
||||||
|
SiteSubscription sub2 = getSubscription(2);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
sub2.getCoverage().setRequestEnvelope(env);
|
||||||
|
sub2.getParameter().clear();
|
||||||
|
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
|
||||||
|
PointTime time = new PointTime();
|
||||||
|
time.setInterval(100);
|
||||||
|
sub2.setTime(time);
|
||||||
|
|
||||||
|
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
sub1, sub2, FIFTY_PERCENT_MATCH_ALL);
|
||||||
|
assertFalse("These should not be duplicates", od.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchAnyWithNoMatches() {
|
||||||
|
SiteSubscription sub1 = getSubscription(1);
|
||||||
|
SiteSubscription sub2 = getSubscription(2);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
sub2.getCoverage().setRequestEnvelope(env);
|
||||||
|
sub2.getParameter().clear();
|
||||||
|
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
|
||||||
|
PointTime time = new PointTime();
|
||||||
|
time.setInterval(100);
|
||||||
|
sub2.setTime(time);
|
||||||
|
|
||||||
|
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
sub1, sub2, FIFTY_PERCENT_MATCH_ANY);
|
||||||
|
assertFalse("These should not be duplicates", od.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchHalfWithNoMatches() {
|
||||||
|
SiteSubscription sub1 = getSubscription(1);
|
||||||
|
SiteSubscription sub2 = getSubscription(2);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
sub2.getCoverage().setRequestEnvelope(env);
|
||||||
|
sub2.getParameter().clear();
|
||||||
|
sub2.addParameter(ParameterFixture.INSTANCE.get(4));
|
||||||
|
PointTime time = new PointTime();
|
||||||
|
time.setInterval(100);
|
||||||
|
sub2.setTime(time);
|
||||||
|
|
||||||
|
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
sub1, sub2, FIFTY_PERCENT_MATCH_HALF);
|
||||||
|
assertFalse("These should not be duplicates", od.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Half matching subs - match parameter and interval
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchAllWithHalfMatches() {
|
||||||
|
SiteSubscription sub1 = getSubscription(1);
|
||||||
|
SiteSubscription sub2 = getSubscription(2);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
sub2.getCoverage().setRequestEnvelope(env);
|
||||||
|
|
||||||
|
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
sub1, sub2, FIFTY_PERCENT_MATCH_ALL);
|
||||||
|
assertFalse("These should not be duplicates", od.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchAnyWithHalfMatches() {
|
||||||
|
SiteSubscription sub1 = getSubscription(1);
|
||||||
|
SiteSubscription sub2 = getSubscription(2);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
sub2.getCoverage().setRequestEnvelope(env);
|
||||||
|
|
||||||
|
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
sub1, sub2, FIFTY_PERCENT_MATCH_ANY);
|
||||||
|
assertFalse("These should not be duplicates", od.isDuplicate());
|
||||||
|
assertTrue("These should not overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFiftyPercentMatchHalfWithHalfMatches() {
|
||||||
|
SiteSubscription sub1 = getSubscription(1);
|
||||||
|
SiteSubscription sub2 = getSubscription(2);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(20, 25, 20, 25,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
sub2.getCoverage().setRequestEnvelope(env);
|
||||||
|
|
||||||
|
PointOverlapData<PointTime, Coverage> od = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
sub1, sub2, FIFTY_PERCENT_MATCH_HALF);
|
||||||
|
assertFalse("These should not be duplicates", od.isDuplicate());
|
||||||
|
assertTrue("These should overlap", od.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAllNotEnoughSpatialOverlap() {
|
||||||
|
int parameter = 100;
|
||||||
|
int spatial = 50;
|
||||||
|
int time = 100;
|
||||||
|
final PointSubscriptionOverlapConfig overlap = new PointSubscriptionOverlapConfig(
|
||||||
|
parameter, time, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.MATCH_ALL);
|
||||||
|
SiteSubscription sub2 = getSubscription(1,
|
||||||
|
areaLessThan50PercentOverlap, createPointTime(30));
|
||||||
|
|
||||||
|
PointOverlapData<PointTime, Coverage> overlapResult = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
matchPoints, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", overlapResult.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAllSpatialOverlap() {
|
||||||
|
int parameter = 100;
|
||||||
|
int spatial = 50;
|
||||||
|
int time = 100;
|
||||||
|
int cycles = 100;
|
||||||
|
final PointSubscriptionOverlapConfig overlap = new PointSubscriptionOverlapConfig(
|
||||||
|
parameter, time, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.MATCH_ALL);
|
||||||
|
SiteSubscription sub3 = getSubscription(1,
|
||||||
|
areaGreaterThan50PercentOverlap, createPointTime(30));
|
||||||
|
|
||||||
|
PointOverlapData<PointTime, Coverage> overlapResult = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
matchPoints, sub3, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAnyParametersOnly() {
|
||||||
|
int parameter = 100;
|
||||||
|
int spatial = 100;
|
||||||
|
int time = 100;
|
||||||
|
final PointSubscriptionOverlapConfig overlap = new PointSubscriptionOverlapConfig(
|
||||||
|
parameter, time, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.MATCH_ANY);
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(1, areaWithNoOverlap,
|
||||||
|
createPointTime(5));
|
||||||
|
|
||||||
|
PointOverlapData<PointTime, Coverage> overlapResult = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
matchPoints, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
assertFalse("These should not overlap",
|
||||||
|
overlapResult.timeDuplicationPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAtLeastHalfParametersAndSpatial() {
|
||||||
|
int parameter = 100;
|
||||||
|
int spatial = 50;
|
||||||
|
int time = 100;
|
||||||
|
final PointSubscriptionOverlapConfig overlap = new PointSubscriptionOverlapConfig(
|
||||||
|
parameter, time, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(1, areaMatchPoints,
|
||||||
|
createPointTime(5));
|
||||||
|
|
||||||
|
PointOverlapData<PointTime, Coverage> overlapResult = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
matchPoints, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
assertFalse("These should not overlap",
|
||||||
|
overlapResult.timeDuplicationPass);
|
||||||
|
assertTrue("These should overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAtLeastHalfSpatialAndTime() {
|
||||||
|
int parameter = 100;
|
||||||
|
int spatial = 50;
|
||||||
|
int time = 100;
|
||||||
|
final PointSubscriptionOverlapConfig overlap = new PointSubscriptionOverlapConfig(
|
||||||
|
parameter, time, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(1,
|
||||||
|
areaGreaterThan50PercentOverlap, createPointTime(30));
|
||||||
|
|
||||||
|
PointOverlapData<PointTime, Coverage> overlapResult = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
matchPoints, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
assertTrue("These should overlap", overlapResult.timeDuplicationPass);
|
||||||
|
assertTrue("These should overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAtLeastHalfParametersAndTime() {
|
||||||
|
int parameter = 100;
|
||||||
|
int spatial = 50;
|
||||||
|
int time = 100;
|
||||||
|
final PointSubscriptionOverlapConfig overlap = new PointSubscriptionOverlapConfig(
|
||||||
|
parameter, time, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(1, areaWithNoOverlap,
|
||||||
|
createPointTime(30));
|
||||||
|
|
||||||
|
PointOverlapData<PointTime, Coverage> overlapResult = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
matchPoints, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertTrue("These should overlap", overlapResult.isOverlapping());
|
||||||
|
assertTrue("These should overlap", overlapResult.timeDuplicationPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMatchAtLeastHalfOneMatch() {
|
||||||
|
int parameter = 100;
|
||||||
|
int spatial = 50;
|
||||||
|
int time = 100;
|
||||||
|
final PointSubscriptionOverlapConfig overlap = new PointSubscriptionOverlapConfig(
|
||||||
|
parameter, time, spatial,
|
||||||
|
SubscriptionOverlapMatchStrategy.AT_LEAST_HALF);
|
||||||
|
|
||||||
|
SiteSubscription sub2 = getSubscription(1, areaWithNoOverlap,
|
||||||
|
createPointTime(10));
|
||||||
|
|
||||||
|
PointOverlapData<PointTime, Coverage> overlapResult = new PointOverlapData<PointTime, Coverage>(
|
||||||
|
matchPoints, sub2, overlap);
|
||||||
|
assertFalse("These should not be duplicates",
|
||||||
|
overlapResult.isDuplicate());
|
||||||
|
assertFalse("These should not overlap", overlapResult.isOverlapping());
|
||||||
|
assertFalse("These should not overlap",
|
||||||
|
overlapResult.timeDuplicationPass);
|
||||||
|
assertFalse("These should not overlap", overlapResult.spatialPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Time createPointTime(int interval) {
|
||||||
|
PointTime time = PointTimeFixture.INSTANCE.get();
|
||||||
|
time.setInterval(interval);
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SiteSubscription getSubscription(int seed) {
|
||||||
|
List<Parameter> parameters = new ArrayList<Parameter>();
|
||||||
|
parameters.add(ParameterFixture.INSTANCE.get());
|
||||||
|
return getSubscription(seed, 0, 0, 15, 15, parameters,
|
||||||
|
PointTimeFixture.INSTANCE.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SiteSubscription getSubscription(int seed, double x1,
|
||||||
|
double y1, double x2, int y2, List<Parameter> parameters, Time time) {
|
||||||
|
SiteSubscription sub = SiteSubscriptionFixture.INSTANCE.get(seed,
|
||||||
|
DataType.POINT);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(x1, x2, y1, y2,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
|
||||||
|
sub.getCoverage().setRequestEnvelope(env);
|
||||||
|
sub.setParameter(parameters);
|
||||||
|
sub.setTime(time);
|
||||||
|
return sub;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SiteSubscription getSubscription(int seed,
|
||||||
|
Envelope envelope, Time time) {
|
||||||
|
SiteSubscription sub = SiteSubscriptionFixture.INSTANCE.get(seed,
|
||||||
|
DataType.POINT);
|
||||||
|
ReferencedEnvelope env = new ReferencedEnvelope(envelope,
|
||||||
|
MapUtil.LATLON_PROJECTION);
|
||||||
|
ArrayList<Parameter> parametersMatchPoints = new ArrayList<Parameter>();
|
||||||
|
parametersMatchPoints.add(ParameterFixture.INSTANCE.get(1));
|
||||||
|
|
||||||
|
sub.getCoverage().setRequestEnvelope(env);
|
||||||
|
sub.setParameter(parametersMatchPoints);
|
||||||
|
sub.setTime(time);
|
||||||
|
return sub;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue