ionutzpi commented on code in PR #41:
URL: 
https://github.com/apache/sling-org-apache-sling-event/pull/41#discussion_r2041866317


##########
src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java:
##########
@@ -300,6 +322,12 @@ private boolean internalRemoveJobById(final String jobId, 
final boolean forceRem
      */
     @Override
     public Job addJob(String topic, Map<String, Object> properties) {
+        // Check health status before adding a job
+        checkHealthStatus();
+        if (!isHealthy) {
+            logger.warn("System is not healthy. Aborting operation.");

Review Comment:
   Remove modification



##########
src/test/java/org/apache/sling/event/impl/jobs/HealthCheckFailureTest.java:
##########
@@ -0,0 +1,208 @@
+/*
+ * 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.sling.event.impl.jobs;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.*;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.felix.hc.api.Result;
+import org.apache.felix.hc.api.execution.HealthCheckExecutionResult;
+import org.apache.felix.hc.api.execution.HealthCheckExecutor;
+import org.apache.felix.hc.api.execution.HealthCheckMetadata;
+import org.apache.felix.hc.api.execution.HealthCheckSelector;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.event.impl.jobs.config.InternalQueueConfiguration;
+import org.apache.sling.event.impl.jobs.config.JobManagerConfiguration;
+import org.apache.sling.event.impl.jobs.config.QueueConfigurationManager;
+import 
org.apache.sling.event.impl.jobs.config.QueueConfigurationManager.QueueInfo;
+import org.apache.sling.event.impl.jobs.config.TopologyCapabilities;
+import org.apache.sling.event.impl.support.ResourceHelper;
+import org.apache.sling.event.jobs.Job;
+import org.apache.sling.testing.mock.sling.junit.SlingContext;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.MockedStatic;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.apache.sling.event.impl.EnvironmentComponent;
+import com.codahale.metrics.MetricRegistry;
+import org.slf4j.Logger;
+
+public class HealthCheckFailureTest {
+
+    @Rule
+    public final SlingContext context = new SlingContext();
+
+    private JobManagerImpl jobManager;
+    private JobManagerConfiguration configuration;
+    private HealthCheckExecutor healthCheckExecutor;
+    private MetricRegistry metricRegistry;
+    private QueueConfigurationManager queueConfigManager;
+    private TopologyCapabilities topologyCapabilities;
+    private ResourceResolver resourceResolver;
+
+    @Before
+    public void setUp() {
+        // Mock QueueConfigurationManager and QueueInfo
+        queueConfigManager = mock(QueueConfigurationManager.class);
+        QueueInfo queueInfo = new QueueInfo();
+        queueInfo.queueName = "test-queue";
+        
when(queueConfigManager.getQueueInfo(any(String.class))).thenReturn(queueInfo);
+        queueInfo.queueConfiguration = new InternalQueueConfiguration();
+
+        // Mock TopologyCapabilities
+        topologyCapabilities = mock(TopologyCapabilities.class);
+        when(topologyCapabilities.detectTarget(any(String.class), 
any(Map.class), any(QueueInfo.class))).thenReturn(null);
+
+        resourceResolver = mock(ResourceResolver.class);

Review Comment:
   Removed class.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to