From b3dd1d8c15fec49581080e331c65296ffb424fd8 Mon Sep 17 00:00:00 2001 From: Manas Ranjan Dikshit Date: Wed, 17 Sep 2025 01:55:32 +0530 Subject: [PATCH 1/7] Update GiraphPagaRankOperatorTest.java --- .../operators/GiraphPagaRankOperatorTest.java | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java index 436c7119a..e4995bf8b 100644 --- a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java +++ b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java @@ -9,11 +9,11 @@ * * 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. + * 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.wayang.giraph.operators; @@ -36,24 +36,25 @@ import java.io.IOException; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; /** * Test For GiraphPageRank */ public class GiraphPagaRankOperatorTest { - private static GiraphExecutor giraphExecutor; + private GiraphExecutor giraphExecutor; @Before public void setUp() { giraphExecutor = mock(GiraphExecutor.class); } - //TODO Validate the mock of GiraphExecutor @Test + @Test public void testExecution() throws IOException { - // Ensure that the GraphChiPlatform is initialized. + // Ensure that the GiraphPlatform is initialized. GiraphPlatform.getInstance(); final Configuration configuration = new Configuration(); Giraph.plugin().configure(configuration); @@ -61,7 +62,8 @@ public void testExecution() throws IOException { final Job job = mock(Job.class); when(job.getConfiguration()).thenReturn(configuration); - when(job.getCrossPlatformExecutor()).thenReturn(new CrossPlatformExecutor(job, new FullInstrumentationStrategy())); + when(job.getCrossPlatformExecutor()) + .thenReturn(new CrossPlatformExecutor(job, new FullInstrumentationStrategy())); final ExecutionOperator outputOperator = mock(ExecutionOperator.class); when(outputOperator.getNumOutputs()).thenReturn(1); @@ -79,13 +81,22 @@ public void testExecution() throws IOException { .createInstance(giraphExecutor, null, -1); final DefaultOptimizationContext optimizationContext = new DefaultOptimizationContext(job); - final OptimizationContext.OperatorContext operatorContext = optimizationContext.addOneTimeOperator(giraphPageRankOperator); + final OptimizationContext.OperatorContext operatorContext = + optimizationContext.addOneTimeOperator(giraphPageRankOperator); + // When: execute the operator giraphPageRankOperator.execute( new ChannelInstance[]{inputChannelInstance}, new ChannelInstance[]{outputFileChannelInstance}, giraphExecutor, operatorContext ); + + // Then: validate interactions with GiraphExecutor + verify(giraphExecutor, atLeastOnce()) + .executeJob(eq(configuration), any(ChannelInstance[].class), any(ChannelInstance[].class), eq(operatorContext)); + + // And: ensure output channel was created + assertNotNull(outputFileChannelInstance); } } From 3f077da0964afff276b027c9148e0c7af274054c Mon Sep 17 00:00:00 2001 From: Manas Ranjan Dikshit Date: Wed, 17 Sep 2025 23:00:24 +0530 Subject: [PATCH 2/7] Update GiraphPagaRankOperatorTest.java --- .../operators/GiraphPagaRankOperatorTest.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java index 8771f082c..efe292ec4 100644 --- a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java +++ b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java @@ -32,12 +32,11 @@ import org.apache.wayang.giraph.platform.GiraphPlatform; import org.apache.wayang.java.channels.StreamChannel; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; @@ -53,17 +52,9 @@ void setUp() { giraphExecutor = mock(GiraphExecutor.class); } - main - @Test - public void testExecution() throws IOException { - // Ensure that the GiraphPlatform is initialized. - - //TODO Validate the mock of GiraphExecutor - @Disabled @Test void testExecution() throws IOException { - // Ensure that the GraphChiPlatform is initialized. - main + // Ensure that the GiraphPlatform is initialized. GiraphPlatform.getInstance(); final Configuration configuration = new Configuration(); Giraph.plugin().configure(configuration); @@ -76,6 +67,7 @@ void testExecution() throws IOException { final ExecutionOperator outputOperator = mock(ExecutionOperator.class); when(outputOperator.getNumOutputs()).thenReturn(1); + FileChannel.Instance inputChannelInstance = (FileChannel.Instance) new FileChannel(FileChannel.HDFS_TSV_DESCRIPTOR) .createInstance(giraphExecutor, null, -1); @@ -84,6 +76,7 @@ void testExecution() throws IOException { final ExecutionOperator inputOperator = mock(ExecutionOperator.class); when(inputOperator.getNumOutputs()).thenReturn(1); + StreamChannel.Instance outputFileChannelInstance = (StreamChannel.Instance) StreamChannel.DESCRIPTOR .createChannel(giraphPageRankOperator.getOutput(), configuration) @@ -103,7 +96,10 @@ void testExecution() throws IOException { // Then: validate interactions with GiraphExecutor verify(giraphExecutor, atLeastOnce()) - .executeJob(eq(configuration), any(ChannelInstance[].class), any(ChannelInstance[].class), eq(operatorContext)); + .executeJob(eq(configuration), + any(ChannelInstance[].class), + any(ChannelInstance[].class), + eq(operatorContext)); // And: ensure output channel was created assertNotNull(outputFileChannelInstance); From 4e48b1b3eb61fd9343d4b48a47a2e7251a4df713 Mon Sep 17 00:00:00 2001 From: Manas Ranjan Dikshit Date: Fri, 19 Sep 2025 00:48:26 +0530 Subject: [PATCH 3/7] Update GiraphPagaRankOperatorTest.java --- .../operators/GiraphPagaRankOperatorTest.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java index efe292ec4..874ec9101 100644 --- a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java +++ b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java @@ -37,11 +37,10 @@ import java.io.IOException; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; /** - * Test For GiraphPageRank + * Test for {@link GiraphPageRankOperator}. */ class GiraphPagaRankOperatorTest { @@ -56,6 +55,7 @@ void setUp() { void testExecution() throws IOException { // Ensure that the GiraphPlatform is initialized. GiraphPlatform.getInstance(); + final Configuration configuration = new Configuration(); Giraph.plugin().configure(configuration); final GiraphPageRankOperator giraphPageRankOperator = new GiraphPageRankOperator(20); @@ -94,14 +94,10 @@ void testExecution() throws IOException { operatorContext ); - // Then: validate interactions with GiraphExecutor - verify(giraphExecutor, atLeastOnce()) - .executeJob(eq(configuration), - any(ChannelInstance[].class), - any(ChannelInstance[].class), - eq(operatorContext)); - - // And: ensure output channel was created + // Then: no exception and output is created assertNotNull(outputFileChannelInstance); + + // And: confirm that our mock executor was used at least once + verify(giraphExecutor, atLeastOnce()).getPlatform(); } } From d464fa4cfcc6f55b22347eb9547822048d2eedc6 Mon Sep 17 00:00:00 2001 From: Manas Ranjan Dikshit Date: Sat, 20 Sep 2025 01:24:26 +0530 Subject: [PATCH 4/7] Update GiraphPagaRankOperatorTest.java --- .../wayang/giraph/operators/GiraphPagaRankOperatorTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java index 874ec9101..a0f6450a8 100644 --- a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java +++ b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java @@ -49,6 +49,8 @@ class GiraphPagaRankOperatorTest { @BeforeEach void setUp() { giraphExecutor = mock(GiraphExecutor.class); + // Stub out getPlatform() so it won’t be null + when(giraphExecutor.getPlatform()).thenReturn(GiraphPlatform.getInstance()); } @Test @@ -57,7 +59,7 @@ void testExecution() throws IOException { GiraphPlatform.getInstance(); final Configuration configuration = new Configuration(); - Giraph.plugin().configure(configuration); + // Do NOT call Giraph.plugin().configure(configuration); → causes NPE final GiraphPageRankOperator giraphPageRankOperator = new GiraphPageRankOperator(20); final Job job = mock(Job.class); @@ -97,7 +99,7 @@ void testExecution() throws IOException { // Then: no exception and output is created assertNotNull(outputFileChannelInstance); - // And: confirm that our mock executor was used at least once + // Verify our mock executor was touched verify(giraphExecutor, atLeastOnce()).getPlatform(); } } From 26c815d7d593c328c7f737efce7c0c2cfb5bccd8 Mon Sep 17 00:00:00 2001 From: Manas Ranjan Dikshit Date: Thu, 2 Oct 2025 00:41:06 +0530 Subject: [PATCH 5/7] Update GiraphPagaRankOperatorTest.java --- .../operators/GiraphPagaRankOperatorTest.java | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java index a0f6450a8..14bc3b1ba 100644 --- a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java +++ b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java @@ -31,16 +31,18 @@ import org.apache.wayang.giraph.execution.GiraphExecutor; import org.apache.wayang.giraph.platform.GiraphPlatform; import org.apache.wayang.java.channels.StreamChannel; +import org.apache.giraph.conf.GiraphConfiguration; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; /** - * Test for {@link GiraphPageRankOperator}. + * Test for GiraphPageRankOperator */ class GiraphPagaRankOperatorTest { @@ -49,23 +51,24 @@ class GiraphPagaRankOperatorTest { @BeforeEach void setUp() { giraphExecutor = mock(GiraphExecutor.class); - // Stub out getPlatform() so it won’t be null - when(giraphExecutor.getPlatform()).thenReturn(GiraphPlatform.getInstance()); + // Stub configuration so executor doesn’t throw NPE + when(giraphExecutor.getConfiguration()).thenReturn(new GiraphConfiguration()); + // Stub execute (void method) + doNothing().when(giraphExecutor).execute(any(), any()); } @Test void testExecution() throws IOException { - // Ensure that the GiraphPlatform is initialized. + // Ensure GiraphPlatform is initialized GiraphPlatform.getInstance(); - final Configuration configuration = new Configuration(); - // Do NOT call Giraph.plugin().configure(configuration); → causes NPE + Giraph.plugin().configure(configuration); + final GiraphPageRankOperator giraphPageRankOperator = new GiraphPageRankOperator(20); final Job job = mock(Job.class); when(job.getConfiguration()).thenReturn(configuration); - when(job.getCrossPlatformExecutor()) - .thenReturn(new CrossPlatformExecutor(job, new FullInstrumentationStrategy())); + when(job.getCrossPlatformExecutor()).thenReturn(new CrossPlatformExecutor(job, new FullInstrumentationStrategy())); final ExecutionOperator outputOperator = mock(ExecutionOperator.class); when(outputOperator.getNumOutputs()).thenReturn(1); @@ -76,10 +79,7 @@ void testExecution() throws IOException { inputChannelInstance.addPath(this.getClass().getResource("/test.edgelist.input").toString()); inputChannelInstance.getLineage().collectAndMark(); - final ExecutionOperator inputOperator = mock(ExecutionOperator.class); - when(inputOperator.getNumOutputs()).thenReturn(1); - - StreamChannel.Instance outputFileChannelInstance = + StreamChannel.Instance outputChannelInstance = (StreamChannel.Instance) StreamChannel.DESCRIPTOR .createChannel(giraphPageRankOperator.getOutput(), configuration) .createInstance(giraphExecutor, null, -1); @@ -88,18 +88,17 @@ void testExecution() throws IOException { final OptimizationContext.OperatorContext operatorContext = optimizationContext.addOneTimeOperator(giraphPageRankOperator); - // When: execute the operator giraphPageRankOperator.execute( new ChannelInstance[]{inputChannelInstance}, - new ChannelInstance[]{outputFileChannelInstance}, + new ChannelInstance[]{outputChannelInstance}, giraphExecutor, operatorContext ); - // Then: no exception and output is created - assertNotNull(outputFileChannelInstance); + // ✅ Verify executor interactions + verify(giraphExecutor, times(1)).execute(any(), any()); - // Verify our mock executor was touched - verify(giraphExecutor, atLeastOnce()).getPlatform(); + // ✅ Assert output channel creation + assertNotNull(outputChannelInstance); } } From bf7e562d4f6d26c063876bdab308c1993caab638 Mon Sep 17 00:00:00 2001 From: Manas Ranjan Dikshit Date: Fri, 14 Nov 2025 01:13:24 +0530 Subject: [PATCH 6/7] Update GiraphPagaRankOperatorTest.java --- .../giraph/operators/GiraphPagaRankOperatorTest.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java index 14bc3b1ba..1bd5e2640 100644 --- a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java +++ b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java @@ -44,22 +44,20 @@ /** * Test for GiraphPageRankOperator */ -class GiraphPagaRankOperatorTest { +class GiraphPageRankOperatorTest { private GiraphExecutor giraphExecutor; @BeforeEach void setUp() { giraphExecutor = mock(GiraphExecutor.class); - // Stub configuration so executor doesn’t throw NPE - when(giraphExecutor.getConfiguration()).thenReturn(new GiraphConfiguration()); - // Stub execute (void method) + GiraphConfiguration mockConfig = mock(GiraphConfiguration.class); + when(giraphExecutor.getConfiguration()).thenReturn(mockConfig); doNothing().when(giraphExecutor).execute(any(), any()); } @Test void testExecution() throws IOException { - // Ensure GiraphPlatform is initialized GiraphPlatform.getInstance(); final Configuration configuration = new Configuration(); Giraph.plugin().configure(configuration); @@ -95,10 +93,10 @@ void testExecution() throws IOException { operatorContext ); - // ✅ Verify executor interactions + // Verify executor interactions verify(giraphExecutor, times(1)).execute(any(), any()); - // ✅ Assert output channel creation + // Assert output channel creation assertNotNull(outputChannelInstance); } } From 902f35fe6adb6484f6633a184acb71fe02196f1d Mon Sep 17 00:00:00 2001 From: Manas Ranjan Dikshit Date: Fri, 14 Nov 2025 01:14:25 +0530 Subject: [PATCH 7/7] Rename test file for GiraphPageRankOperator --- ...hPagaRankOperatorTest.java => GiraphPageRankOperatorTest.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/{GiraphPagaRankOperatorTest.java => GiraphPageRankOperatorTest.java} (100%) diff --git a/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java b/wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPageRankOperatorTest.java similarity index 100% rename from wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPagaRankOperatorTest.java rename to wayang-platforms/wayang-giraph/src/test/java/org/apache/wayang/giraph/operators/GiraphPageRankOperatorTest.java