You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2023/01/03 09:03:06 UTC
[streampipes] 02/02: [#1026] Fix junit tests in streampipes-pipeline-management
This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch SP-1026
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 86f87af148643b5641d0f259ae79ac0c4110c6ff
Author: Philipp Zehnder <te...@users.noreply.github.com>
AuthorDate: Tue Jan 3 10:02:48 2023 +0100
[#1026] Fix junit tests in streampipes-pipeline-management
---
.../format/json/arraykey/JsonParserTest.java | 3 +-
.../streampipes/manager/ThrowableCaptor.java | 42 ----------
.../manager/assets/TestImagePathReplacer.java | 31 ++++----
.../manager/matching/TestPipelineModification.java | 66 ----------------
.../matching/TestPipelineValidationHandler.java | 64 ----------------
.../streampipes/manager/matching/TestRdfId.java | 49 ------------
.../manager/matching/v2/ListPropertyMatchTest.java | 4 +-
.../manager/matching/v2/TestDatatypeMatch.java | 6 +-
.../matching/v2/TestDomainPropertyMatch.java | 9 ++-
.../matching/v2/TestElementVerification.java | 41 ----------
.../manager/matching/v2/TestFormatMatch.java | 6 +-
.../manager/matching/v2/TestGroundingMatch.java | 21 +----
.../matching/v2/TestMeasurementUnitMatch.java | 5 +-
.../matching/v2/TestPrimitivePropertyMatch.java | 6 +-
.../manager/matching/v2/TestProtocolMatch.java | 6 +-
.../manager/matching/v2/TestSchemaMatch.java | 6 +-
.../streampipes/manager/matching/v2/TestUtils.java | 59 --------------
.../manager/pipeline/TestPipelineManager.java | 9 ---
.../pipeline/TestPipelinesContainingElements.java | 89 ----------------------
.../manager/selector/TestPropertyRenaming.java | 1 -
.../streampipes/manager/selector/TestSelector.java | 9 +--
21 files changed, 56 insertions(+), 476 deletions(-)
diff --git a/streampipes-extensions-management/src/test/java/org/apache/streampipes/extensions/management/connect/adapter/format/json/arraykey/JsonParserTest.java b/streampipes-extensions-management/src/test/java/org/apache/streampipes/extensions/management/connect/adapter/format/json/arraykey/JsonParserTest.java
index d8f6e47f2..77a6335fb 100644
--- a/streampipes-extensions-management/src/test/java/org/apache/streampipes/extensions/management/connect/adapter/format/json/arraykey/JsonParserTest.java
+++ b/streampipes-extensions-management/src/test/java/org/apache/streampipes/extensions/management/connect/adapter/format/json/arraykey/JsonParserTest.java
@@ -18,9 +18,10 @@
package org.apache.streampipes.extensions.management.connect.adapter.format.json.arraykey;
+import org.apache.streampipes.extensions.management.connect.adapter.TestUtils;
+
import com.google.gson.JsonObject;
import org.apache.commons.io.IOUtils;
-import org.apache.streampipes.extensions.management.connect.adapter.TestUtils;
import org.junit.Test;
import java.io.InputStream;
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/ThrowableCaptor.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/ThrowableCaptor.java
deleted file mode 100644
index f089030f5..000000000
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/ThrowableCaptor.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.manager;
-
-/**
- * Helper class to assert exceptions
- * See http://www.codeaffine.com/2014/07/28/clean-junit-throwable-tests-with-java-8-lambdas/
- */
-public class ThrowableCaptor {
-
- public interface Actor {
- void act() throws Throwable;
- }
-
- public static Throwable captureThrowable(Actor actor) {
- Throwable result = null;
- try {
- actor.act();
- } catch (Throwable throwable) {
- result = throwable;
- }
- return result;
- }
-
-
-}
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/assets/TestImagePathReplacer.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/assets/TestImagePathReplacer.java
index 9de021e01..aafb2be34 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/assets/TestImagePathReplacer.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/assets/TestImagePathReplacer.java
@@ -24,27 +24,28 @@ import static org.junit.Assert.assertEquals;
public class TestImagePathReplacer {
- private String testContent = "## Numerical Filter\n"
- + "\n"
- + "<img src=\"logo.png\"/>\n"
- + "\n"
- + "## Description\n"
- + "\n"
- + "Lorem ipsu";
+ private static final String testContentReplaced = """
+ ## Numerical Filter
- private String testContentReplaced = "## Numerical Filter\n"
- + "\n"
- + "<img src=\"/streampipes-backend/api/v2/pe/app/assets/logo.png\"/>\n"
- + "\n"
- + "## Description\n"
- + "\n"
- + "Lorem ipsu";
+ <img src="/streampipes-backend/api/v2/pe/app/assets/logo.png"/>
- private String appId = "app";
+ ## Description
+
+ Lorem ipsu""";
+
+ private static final String appId = "app";
@Test
public void testRegexReplacement() {
+ String testContent = """
+ ## Numerical Filter
+
+ <img src="logo.png"/>
+
+ ## Description
+
+ Lorem ipsu""";
String newContent = new ImagePathReplacer(testContent, appId).replaceContent();
assertEquals(testContentReplaced, newContent);
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/TestPipelineModification.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/TestPipelineModification.java
deleted file mode 100644
index 2dd8dcde5..000000000
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/TestPipelineModification.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.manager.matching;
-
-public class TestPipelineModification {
-
-// @Test
-// public void testPipelineModificationMessagePresent() {
-//
-// DataProcessorInvocation invocation = TestUtils.makeSepa(new AggregationController(), "B", "A");
-// SpDataStream stream = TestUtils.makeStream(new RandomDataProducer(), new RandomNumberStreamJson(), "A");
-//
-// Pipeline pipeline =TestUtils.makePipeline(Arrays.asList(stream), Arrays.asList(invocation));
-//
-// PipelineModificationMessage message = null;
-// try {
-// message = new PipelineVerificationHandler(pipeline)
-// .validateConnection()
-// .computeMappingProperties()
-// .getPipelineModificationMessage();
-// } catch (Exception e) {
-// fail(e.toString());
-// }
-//
-// assertNotNull(message);
-// }
-
-// @Test
-// public void testPipelineMappingProperties() {
-//
-// DataProcessorInvocation invocation = TestUtils.makeSepa(new AggregationController(), "B", "A");
-// SpDataStream stream = TestUtils.makeStream(new RandomDataProducer(), new RandomNumberStreamJson(), "A");
-//
-// Pipeline pipeline =TestUtils.makePipeline(Arrays.asList(stream), Arrays.asList(invocation));
-//
-// PipelineModificationMessage message = null;
-// try {
-// message = new PipelineVerificationHandler(pipeline)
-// .validateConnection()
-// .computeMappingProperties()
-// .getPipelineModificationMessage();
-// } catch (Exception e) {
-// fail("Exception");
-// }
-//
-// assertNotNull(message);
-// assertTrue(message.getPipelineModifications().size() > 0);
-// }
-
-}
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/TestPipelineValidationHandler.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/TestPipelineValidationHandler.java
deleted file mode 100644
index fdd6357d3..000000000
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/TestPipelineValidationHandler.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.manager.matching;
-
-//import static org.assertj.core.api.Assertions.assertThat;
-
-public class TestPipelineValidationHandler {
-
-// @Test
-// public void testPositivePipelineValidation() {
-//
-// Pipeline pipeline = TestUtils.makePipeline(new RandomDataProducer(),
-// new RandomNumberStreamJson(),
-// new AggregationController());
-//
-// PipelineVerificationHandler handler;
-// try {
-// handler = new PipelineVerificationHandler(pipeline);
-// handler.validateConnection();
-// } catch (Exception e2) {
-// fail(e2.getMessage());
-// }
-//
-// assertTrue(true);
-// }
-//
-// @Test
-// public void testNegativePipelineValidation() {
-//
-// Pipeline pipeline = TestUtils.makePipeline(new RandomDataProducer(),
-// new RandomNumberStreamJson(),
-// new GeofencingController());
-//
-// PipelineVerificationHandler handler = null;
-//
-//
-// try {
-// handler = new PipelineVerificationHandler(pipeline);
-// } catch (Exception e) {
-// assertTrue(false);
-// }
-//
-// Throwable actual = ThrowableCaptor.captureThrowable(handler::validateConnection);
-//
-// //assertThat(actual).isInstanceOf(InvalidConnectionException.class);
-//
-// }
-}
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/TestRdfId.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/TestRdfId.java
deleted file mode 100644
index d53114883..000000000
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/TestRdfId.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.manager.matching;
-
-public class TestRdfId {
-
-// @Test
-// public void testGraphIdAfterClone() {
-//
-// DataProcessorInvocation invocation = TestUtils.makeSepa(new ProjectController(), "A", "B");
-// SpDataStream stream = TestUtils.makeStream(new RandomDataProducer(), new RandomNumberStreamJson(), "B");
-//
-// SpDataStream clonedStream = new SpDataStream(stream);
-//
-// assertEquals(stream.getElementId(), clonedStream.getElementId());
-//
-// CustomOutputStrategy strategy = (CustomOutputStrategy) invocation.getOutputStrategies().get(0);
-// strategy.setEventProperties(clonedStream.getEventSchema().getEventProperties());
-//
-// assertEquals(clonedStream.getEventSchema().getEventProperties().get(0).getElementId(),
-// strategy.getEventProperties().get(0).getElementId());
-//
-// DataProcessorInvocation invocation2 = new DataProcessorInvocation(invocation);
-//
-// CustomOutputStrategy strategy2 = (CustomOutputStrategy) invocation2.getOutputStrategies().get(0);
-//
-// assertEquals(clonedStream.getEventSchema().getEventProperties().get(0).getElementId(),
-// strategy2.getEventProperties().get(0).getElementId());
-//
-//
-//
-// }
-}
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/ListPropertyMatchTest.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/ListPropertyMatchTest.java
index 29b5b6305..019616adf 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/ListPropertyMatchTest.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/ListPropertyMatchTest.java
@@ -33,7 +33,7 @@ public class ListPropertyMatchTest {
@Test
- public void matchSameDomainProperty() throws Exception {
+ public void matchSameDomainProperty() {
List<URI> domainProperties = new ArrayList<>();
domainProperties.add(URI.create("http://test.org/property"));
@@ -50,7 +50,7 @@ public class ListPropertyMatchTest {
}
@Test
- public void matchListWithNoFurtherRequirements() throws Exception {
+ public void matchListWithNoFurtherRequirements() {
EventPropertyList offer = new EventPropertyList();
EventPropertyList requirement = new EventPropertyList();
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestDatatypeMatch.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestDatatypeMatch.java
index 36c82fcdf..f9957e38a 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestDatatypeMatch.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestDatatypeMatch.java
@@ -22,13 +22,15 @@ import org.apache.streampipes.model.client.matching.MatchingResultMessage;
import org.apache.streampipes.vocabulary.SO;
import org.apache.streampipes.vocabulary.XSD;
-import junit.framework.TestCase;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-public class TestDatatypeMatch extends TestCase {
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class TestDatatypeMatch {
@Test
public void testPositiveDatatypeMatch() {
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestDomainPropertyMatch.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestDomainPropertyMatch.java
index 4f55a8aee..bd77a8a7f 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestDomainPropertyMatch.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestDomainPropertyMatch.java
@@ -21,15 +21,16 @@ package org.apache.streampipes.manager.matching.v2;
import org.apache.streampipes.model.client.matching.MatchingResultMessage;
import org.apache.streampipes.vocabulary.Geo;
-import junit.framework.TestCase;
import org.junit.Test;
import java.net.URI;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-public class TestDomainPropertyMatch extends TestCase {
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class TestDomainPropertyMatch {
@Test
public void testPositiveDomainPropertyMatch() {
@@ -56,6 +57,6 @@ public class TestDomainPropertyMatch extends TestCase {
}
private List<URI> buildDomainProperties(String name) {
- return Arrays.asList(URI.create(name));
+ return List.of(URI.create(name));
}
}
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestElementVerification.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestElementVerification.java
deleted file mode 100644
index cd10eda9e..000000000
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestElementVerification.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.manager.matching.v2;
-
-import junit.framework.TestCase;
-import org.junit.Test;
-
-public class TestElementVerification extends TestCase {
-
- @Test
- public void testPositive() {
-
-// RandomDataProducer producer = new RandomDataProducer();
-// SpDataStream offer = producer.getEventStreams().get(0).declareModel(producer.declareModel());
-//
-// DataProcessorDescription requirement = (new AggregationController().declareModel());
-//
-// ElementVerification verifier = new ElementVerification();
-// boolean match = verifier.verify(offer, new DataProcessorInvocation(requirement));
-//
-// verifier.getErrorLog().forEach(e -> System.out.println(e.getTitle()));
- assertTrue(true);
-
- }
-}
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestFormatMatch.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestFormatMatch.java
index b340ff7ea..25820bc70 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestFormatMatch.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestFormatMatch.java
@@ -21,13 +21,15 @@ package org.apache.streampipes.manager.matching.v2;
import org.apache.streampipes.model.client.matching.MatchingResultMessage;
import org.apache.streampipes.model.grounding.TransportFormat;
-import junit.framework.TestCase;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-public class TestFormatMatch extends TestCase {
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class TestFormatMatch {
@Test
public void testPositiveFormatMatch() {
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestGroundingMatch.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestGroundingMatch.java
index e8928b393..c48569cc3 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestGroundingMatch.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestGroundingMatch.java
@@ -23,13 +23,15 @@ import org.apache.streampipes.model.grounding.EventGrounding;
import org.apache.streampipes.model.grounding.TransportFormat;
import org.apache.streampipes.model.grounding.TransportProtocol;
-import junit.framework.TestCase;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-public class TestGroundingMatch extends TestCase {
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class TestGroundingMatch {
@Test
public void testPositiveGroundingMatch() {
@@ -103,19 +105,4 @@ public class TestGroundingMatch extends TestCase {
assertFalse(matches);
}
- @Test
- public void testPositiveGroundingMatchWithRealEpa() {
-
-// RandomDataProducer producer = new RandomDataProducer();
-// SpDataStream offer = producer.getEventStreams().get(0).declareModel(producer.declareModel());
-//
-// DataProcessorDescription requirement = (new AggregationController().declareModel());
-//
-// List<MatchingResultMessage> errorLog = new ArrayList<>();
-// boolean match = new GroundingMatch().match(offer.getEventGrounding(),
-// requirement.getSupportedGrounding(), errorLog);
-
- assertTrue(true);
-
- }
}
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestMeasurementUnitMatch.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestMeasurementUnitMatch.java
index 473dcffdd..81e6f5a59 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestMeasurementUnitMatch.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestMeasurementUnitMatch.java
@@ -20,14 +20,15 @@ package org.apache.streampipes.manager.matching.v2;
import org.apache.streampipes.model.client.matching.MatchingResultMessage;
-import junit.framework.TestCase;
import org.junit.Test;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
-public class TestMeasurementUnitMatch extends TestCase {
+import static org.junit.Assert.assertTrue;
+
+public class TestMeasurementUnitMatch {
@Test
public void testPositiveMeasurementUnitMatch() {
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestPrimitivePropertyMatch.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestPrimitivePropertyMatch.java
index af5718996..240940fda 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestPrimitivePropertyMatch.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestPrimitivePropertyMatch.java
@@ -25,13 +25,15 @@ import org.apache.streampipes.sdk.helpers.EpRequirements;
import org.apache.streampipes.sdk.helpers.Labels;
import org.apache.streampipes.vocabulary.Geo;
-import junit.framework.TestCase;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-public class TestPrimitivePropertyMatch extends TestCase {
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class TestPrimitivePropertyMatch {
@Test
public void testPositivePrimitivePropertyMatch() {
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestProtocolMatch.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestProtocolMatch.java
index 6553928ed..98d315183 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestProtocolMatch.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestProtocolMatch.java
@@ -21,13 +21,15 @@ package org.apache.streampipes.manager.matching.v2;
import org.apache.streampipes.model.client.matching.MatchingResultMessage;
import org.apache.streampipes.model.grounding.TransportProtocol;
-import junit.framework.TestCase;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
-public class TestProtocolMatch extends TestCase {
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class TestProtocolMatch {
@Test
public void testPositiveProtocolMatch() {
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestSchemaMatch.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestSchemaMatch.java
index 8b102223c..e2696f6c7 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestSchemaMatch.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestSchemaMatch.java
@@ -27,14 +27,16 @@ import org.apache.streampipes.sdk.helpers.EpRequirements;
import org.apache.streampipes.sdk.helpers.Labels;
import org.apache.streampipes.vocabulary.Geo;
-import junit.framework.TestCase;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-public class TestSchemaMatch extends TestCase {
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class TestSchemaMatch {
@Test
public void testPositiveSchemaMatch() {
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestUtils.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestUtils.java
index 5d362903a..d1e31832e 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestUtils.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/matching/v2/TestUtils.java
@@ -18,24 +18,12 @@
package org.apache.streampipes.manager.matching.v2;
-import org.apache.streampipes.extensions.api.declarer.EventStreamDeclarer;
-import org.apache.streampipes.extensions.api.declarer.SemanticEventProcessingAgentDeclarer;
-import org.apache.streampipes.extensions.api.declarer.SemanticEventProducerDeclarer;
-import org.apache.streampipes.model.SpDataStream;
-import org.apache.streampipes.model.graph.DataProcessorDescription;
-import org.apache.streampipes.model.graph.DataProcessorInvocation;
-import org.apache.streampipes.model.graph.DataSourceDescription;
import org.apache.streampipes.model.grounding.JmsTransportProtocol;
import org.apache.streampipes.model.grounding.KafkaTransportProtocol;
import org.apache.streampipes.model.grounding.TransportFormat;
import org.apache.streampipes.model.grounding.TransportProtocol;
-import org.apache.streampipes.model.pipeline.Pipeline;
import org.apache.streampipes.vocabulary.MessageFormat;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
public class TestUtils {
public static TransportProtocol kafkaProtocol() {
@@ -54,51 +42,4 @@ public class TestUtils {
return new TransportFormat(MessageFormat.THRIFT);
}
- public static Pipeline makePipeline(SemanticEventProducerDeclarer producer, EventStreamDeclarer stream,
- SemanticEventProcessingAgentDeclarer agent) {
- DataSourceDescription dataSourceDescription = new DataSourceDescription(producer.declareModel());
- dataSourceDescription.setElementId("http://www.schema.org/test1");
- SpDataStream offer = stream.declareModel();
- offer.setElementId("http://www.schema.org/test2");
- DataProcessorDescription requirement = (agent.declareModel());
- requirement.setElementId("http://www.schema.org/test3");
- Pipeline pipeline = new Pipeline();
- SpDataStream offeredClientModel = offer;
- offeredClientModel.setDom("A");
-
- DataProcessorInvocation requiredClientModel = new DataProcessorInvocation(requirement);
- requiredClientModel.setDom("B");
- requiredClientModel.setConnectedTo(Arrays.asList("A"));
-
- pipeline.setStreams(Arrays.asList(offeredClientModel));
- pipeline.setSepas(Arrays.asList(requiredClientModel));
-
-
- return pipeline;
- }
-
- public static Pipeline makePipeline(List<SpDataStream> streams, List<DataProcessorInvocation> epas) {
- Pipeline pipeline = new Pipeline();
-
- pipeline.setStreams(streams.stream().map(s -> new SpDataStream(s)).collect(Collectors.toList()));
- pipeline.setSepas(epas.stream().map(s -> new DataProcessorInvocation(s)).collect(Collectors.toList()));
-
- return pipeline;
- }
-
- public static DataProcessorInvocation makeSepa(SemanticEventProcessingAgentDeclarer declarer, String domId,
- String... connectedTo) {
- DataProcessorInvocation invocation = new DataProcessorInvocation(declarer.declareModel());
- invocation.setDom(domId);
- invocation.setConnectedTo(Arrays.asList(connectedTo));
- return invocation;
- }
-
- public static SpDataStream makeStream(SemanticEventProducerDeclarer declarer, EventStreamDeclarer streamDec,
- String domId) {
- SpDataStream stream = new SpDataStream(streamDec.declareModel());
- stream.setDom(domId);
- return stream;
- }
-
}
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/pipeline/TestPipelineManager.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/pipeline/TestPipelineManager.java
index 7938de77a..3d0feae91 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/pipeline/TestPipelineManager.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/pipeline/TestPipelineManager.java
@@ -20,10 +20,8 @@ package org.apache.streampipes.manager.pipeline;
import org.apache.streampipes.manager.operations.Operations;
import org.apache.streampipes.model.pipeline.Pipeline;
import org.apache.streampipes.model.pipeline.PipelineOperationStatus;
-import org.apache.streampipes.resource.management.UserResourceManager;
import org.apache.streampipes.test.generator.pipeline.DummyPipelineGenerator;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
@@ -37,17 +35,10 @@ import static junit.framework.TestCase.assertNotNull;
@RunWith(PowerMockRunner.class)
@PrepareForTest({
- UserResourceManager.class,
PipelineManager.class,
Operations.class})
public class TestPipelineManager {
- @Before
- public void before() {
- PowerMockito.mockStatic(
- UserResourceManager.class);
- }
-
@Test
public void testStartPipeline() {
// Prepare
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/pipeline/TestPipelinesContainingElements.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/pipeline/TestPipelinesContainingElements.java
deleted file mode 100644
index bc35b3b74..000000000
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/pipeline/TestPipelinesContainingElements.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.streampipes.manager.pipeline;
-
-import org.apache.streampipes.model.pipeline.Pipeline;
-import org.apache.streampipes.test.generator.pipeline.DummyPipelineGenerator;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import java.util.Collections;
-import java.util.List;
-
-import static junit.framework.TestCase.assertEquals;
-import static junit.framework.TestCase.assertNotNull;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({
- PipelineManager.class})
-public class TestPipelinesContainingElements {
- public static final String TARGET_ELEMENT_ID = "TARGET_ELEMENT_ID";
-
- private Pipeline pipeline;
-
- @Before
- public void before() {
- pipeline = DummyPipelineGenerator.makePipelineWithProcessorAndSink();
- PowerMockito.stub(PowerMockito.method(PipelineManager.class, "getAllPipelines"))
- .toReturn(Collections.singletonList(pipeline));
- }
-
- @Test
- public void getPipelineContainingNoElement() {
- List<Pipeline> resultingPipelines = PipelineManager.getPipelinesContainingElements("");
- assertNotNull(resultingPipelines);
- assertEquals(resultingPipelines.size(), 0);
- }
-
- @Test
- public void getPipelineContainingStream() {
- pipeline.getStreams().forEach((spDataStream) -> spDataStream.setElementId(TARGET_ELEMENT_ID));
-
- validateOneResultingPipeline();
- }
-
-
- @Test
- public void getPipelineContainingProcessor() {
-
- pipeline.getSepas().forEach((processor) -> processor.setElementId(TARGET_ELEMENT_ID));
-
- validateOneResultingPipeline();
- }
-
- @Test
- public void getPipelineContainingSink() {
-
- pipeline.getActions().forEach((sink) -> sink.setElementId(TARGET_ELEMENT_ID));
-
- validateOneResultingPipeline();
- }
-
- private void validateOneResultingPipeline() {
- List<Pipeline> resultingPipelines = PipelineManager.getPipelinesContainingElements(TARGET_ELEMENT_ID);
- assertNotNull(resultingPipelines);
- assertEquals(resultingPipelines.size(), 1);
- assertEquals(resultingPipelines.get(0).getName(), DummyPipelineGenerator.PIPELINE_NAME);
- }
-
-}
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/selector/TestPropertyRenaming.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/selector/TestPropertyRenaming.java
index 89bdec2df..7956caea6 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/selector/TestPropertyRenaming.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/selector/TestPropertyRenaming.java
@@ -31,7 +31,6 @@ import static org.junit.Assert.assertEquals;
public class TestPropertyRenaming {
-
@Test
public void testRenaming() {
EventSchema schema1 = TestSelectorUtils.makeSimpleSchema();
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/selector/TestSelector.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/selector/TestSelector.java
index e7226a563..ceccf5237 100644
--- a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/selector/TestSelector.java
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/selector/TestSelector.java
@@ -23,7 +23,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
-import java.util.Arrays;
import java.util.List;
import static org.apache.streampipes.manager.selector.TestSelectorUtils.makeSchema;
@@ -34,10 +33,10 @@ public class TestSelector {
@Parameterized.Parameters
public static Iterable<Object[]> data() {
- return Arrays.asList(new Object[][]{
- {Arrays.asList("s0::testDimension"), 1},
- {Arrays.asList("s0::location", "s0::location::latitude"), 1},
- {Arrays.asList("s0::testDimension", "s0::testMeasurement"), 2}
+ return List.of(new Object[][]{
+ {List.of("s0::testDimension"), 1},
+ {List.of("s0::location", "s0::location::latitude"), 1},
+ {List.of("s0::testDimension", "s0::testMeasurement"), 2}
});
}