Skip to content

Commit

Permalink
Some minor improvements on CopySpaceStepsTest
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Rögner <[email protected]>
  • Loading branch information
roegi committed Dec 16, 2024
1 parent 301220b commit b867c2e
Showing 1 changed file with 32 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@

public class CopySpaceStepsTest extends StepTest {

static private String SrcSpc = "testCopy-Source-07",
TrgSpc = "testCopy-Target-07",
OtherCntr = "psql_db2_hashed",
TrgRmtSpc = "testCopy-Target-07-remote",
static private String sourceSpace = "testCopy-Source-07",
targetSpace = "testCopy-Target-07",
otherConnector = "psql_db2_hashed",
targetRemoteSpace = "testCopy-Target-07-remote",
propertyFilter = "p.all=common";

static private Polygon spatialSearchGeom;
Expand All @@ -78,25 +78,25 @@ public class CopySpaceStepsTest extends StepTest {
@BeforeEach
public void setup() throws SQLException {
cleanup();
createSpace(new Space().withId(SrcSpc).withVersionsToKeep(100),false);
createSpace(new Space().withId(TrgSpc).withVersionsToKeep(100),false);
createSpace(new Space().withId(TrgRmtSpc).withVersionsToKeep(100).withStorage(new ConnectorRef().withId(OtherCntr)),false);
createSpace(new Space().withId(sourceSpace).withVersionsToKeep(100),false);
createSpace(new Space().withId(targetSpace).withVersionsToKeep(100),false);
createSpace(new Space().withId(targetRemoteSpace).withVersionsToKeep(100).withStorage(new ConnectorRef().withId(otherConnector)),false);

//write features source
putRandomFeatureCollectionToSpace(SrcSpc, 20,xmin,ymin,xmax,ymax);
putRandomFeatureCollectionToSpace(SrcSpc, 20,xmin,ymin,xmax,ymax);
putRandomFeatureCollectionToSpace(sourceSpace, 20,xmin,ymin,xmax,ymax);
putRandomFeatureCollectionToSpace(sourceSpace, 20,xmin,ymin,xmax,ymax);
//write features target - non-empty-space
putRandomFeatureCollectionToSpace(TrgSpc, 2,xmin,ymin,xmax,ymax);
putRandomFeatureCollectionToSpace(targetSpace, 2,xmin,ymin,xmax,ymax);

putRandomFeatureCollectionToSpace(TrgRmtSpc, 2,xmin,ymin,xmax,ymax);
putRandomFeatureCollectionToSpace(targetRemoteSpace, 2,xmin,ymin,xmax,ymax);

}

@AfterEach
public void cleanup() throws SQLException {
deleteSpace(SrcSpc);
deleteSpace(TrgSpc);
deleteSpace(TrgRmtSpc);
deleteSpace(sourceSpace);
deleteSpace(targetSpace);
deleteSpace(targetRemoteSpace);
}

private static Stream<Arguments> provideParameters() {
Expand All @@ -121,15 +121,15 @@ private static Stream<Arguments> provideParameters() {
@MethodSource("provideParameters")
public void copySpace( boolean testRemoteDb, Geometry geo, boolean clip, String propertyFilter) throws Exception {

String targetSpace = !testRemoteDb ? TrgSpc : TrgRmtSpc;
String targetSpace = !testRemoteDb ? CopySpaceStepsTest.targetSpace : targetRemoteSpace;

StatisticsResponse statsBefore = getStatistics(targetSpace);

assertEquals(2L, (Object) statsBefore.getCount().getValue());

LambdaBasedStep step = new CopySpace()
//.withVersion(7499)
.withSpaceId(SrcSpc).withSourceVersionRef(new Ref("HEAD"))
.withSpaceId(sourceSpace).withSourceVersionRef(new Ref("HEAD"))
.withGeometry( geo ).withClipOnFilterGeometry(clip)
.withPropertyFilter(PropertiesQuery.fromString(propertyFilter))
.withTargetSpaceId( targetSpace )
Expand All @@ -145,7 +145,7 @@ public void copySpace( boolean testRemoteDb, Geometry geo, boolean clip, String
public void copySpacePre( ) throws Exception {

LambdaBasedStep step = new CopySpacePre()
.withSpaceId(SrcSpc)
.withSpaceId(sourceSpace)
.withJobId( JOB_ID );

sendLambdaStepRequestBlock(step, true);
Expand All @@ -160,26 +160,24 @@ public void copySpacePre( ) throws Exception {
assertEquals(3L, fetchedVersion);
}

@Test
public void copySpacePost( ) throws Exception {

LambdaBasedStep step = new CopySpacePost()
.withSpaceId(SrcSpc)
.withJobId( JOB_ID );

sendLambdaStepRequestBlock(step, true);
@Test
public void copySpacePost() throws Exception {
LambdaBasedStep step = new CopySpacePost()
.withSpaceId(sourceSpace)
.withJobId(JOB_ID);

List<?> outputs = step.loadOutputs(USER);
sendLambdaStepRequestBlock(step, true);

FeatureStatistics featureStatistics = null;
List<?> outputs = step.loadOutputs(USER);

for( Object output : outputs)
if( output instanceof FeatureStatistics ftstat )
featureStatistics = ftstat;
FeatureStatistics featureStatistics = null;

assertTrue( featureStatistics != null
&& featureStatistics.getFeatureCount() == 0
&& featureStatistics.getByteSize() == 0 );
}
for (Object output : outputs)
if (output instanceof FeatureStatistics statistics)
featureStatistics = statistics;

assertTrue(featureStatistics != null
&& featureStatistics.getFeatureCount() == 0
&& featureStatistics.getByteSize() == 0);
}
}

0 comments on commit b867c2e

Please sign in to comment.