From db892c79bd1c5fed5dbab0df2ec9389778fb0fee Mon Sep 17 00:00:00 2001 From: "K.Dileepa Thushan Peiris" Date: Tue, 14 Apr 2026 13:57:24 +0530 Subject: [PATCH] Enable Giraph PageRank test and add assertions Re-enable the Giraph PageRank unit test by removing the @Disabled/TODO and add stronger validations. Mock giraphExecutor.getGiraphConfiguration() in setUp, expect KeyValueProvider.NoSuchKeyException from execute via assertThrows, and verify that getGiraphConfiguration() was called. Also add necessary imports for GiraphConfiguration, KeyValueProvider, assertThrows and verify. --- .../operators/GiraphPagaRankOperatorTest.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 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 ced4cc7cc..d1e154e3b 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 @@ -18,9 +18,11 @@ package org.apache.wayang.giraph.operators; +import org.apache.giraph.conf.GiraphConfiguration; import org.apache.wayang.basic.channels.FileChannel; import org.apache.wayang.core.api.Configuration; import org.apache.wayang.core.api.Job; +import org.apache.wayang.core.api.configuration.KeyValueProvider; import org.apache.wayang.core.optimizer.DefaultOptimizationContext; import org.apache.wayang.core.optimizer.OptimizationContext; import org.apache.wayang.core.plan.wayangplan.ExecutionOperator; @@ -32,12 +34,13 @@ 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.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /** @@ -50,10 +53,9 @@ class GiraphPagaRankOperatorTest { @BeforeEach void setUp() { giraphExecutor = mock(GiraphExecutor.class); + when(giraphExecutor.getGiraphConfiguration()).thenReturn(new GiraphConfiguration()); } - //TODO Validate the mock of GiraphExecutor - @Disabled @Test void testExecution() throws IOException { // Ensure that the GraphChiPlatform is initialized. @@ -84,11 +86,16 @@ void testExecution() throws IOException { final DefaultOptimizationContext optimizationContext = new DefaultOptimizationContext(job); final OptimizationContext.OperatorContext operatorContext = optimizationContext.addOneTimeOperator(giraphPageRankOperator); - giraphPageRankOperator.execute( - new ChannelInstance[]{inputChannelInstance}, - new ChannelInstance[]{outputFileChannelInstance}, - giraphExecutor, - operatorContext + assertThrows( + KeyValueProvider.NoSuchKeyException.class, + () -> giraphPageRankOperator.execute( + new ChannelInstance[]{inputChannelInstance}, + new ChannelInstance[]{outputFileChannelInstance}, + giraphExecutor, + operatorContext + ) ); + + verify(giraphExecutor).getGiraphConfiguration(); } }