This is an automated email from the ASF dual-hosted git repository.

arnold pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new a38fc3231 Disable receiving events for batch-only instances
a38fc3231 is described below

commit a38fc32315ae64793671d091583858ba7928d6ad
Author: Jose Alberto Hernandez <[email protected]>
AuthorDate: Sun Jun 5 10:32:32 2022 -0500

    Disable receiving events for batch-only instances
---
 ...a => EnableFineractEventListenerCondition.java} |  15 ++-
 .../core/config/EnableFineractEventsCondition.java |  10 +-
 .../api/FineractInstanceModeConstants.java         |  31 +++++++
 .../ActiveMQNotificationEventListener.java         |   4 +-
 .../EnableFineractEventListenerConditionTest.java  | 102 +++++++++++++++++++++
 .../instancemode/InstanceModeMock.java             |  37 ++++++++
 .../filter/FineractInstanceModeApiFilterTest.java  |  35 +++----
 7 files changed, 203 insertions(+), 31 deletions(-)

diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/EnableFineractEventsCondition.java
 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/EnableFineractEventListenerCondition.java
similarity index 57%
copy from 
fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/EnableFineractEventsCondition.java
copy to 
fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/EnableFineractEventListenerCondition.java
index 1c3f6710d..3c963bd72 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/EnableFineractEventsCondition.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/EnableFineractEventListenerCondition.java
@@ -19,20 +19,25 @@
 package org.apache.fineract.infrastructure.core.config;
 
 import java.util.Optional;
+import 
org.apache.fineract.infrastructure.instancemode.api.FineractInstanceModeConstants;
 import org.springframework.context.annotation.Condition;
 import org.springframework.context.annotation.ConditionContext;
 import org.springframework.core.type.AnnotatedTypeMetadata;
 
-public class EnableFineractEventsCondition implements Condition {
+public class EnableFineractEventListenerCondition implements Condition {
 
     @Override
     public boolean matches(ConditionContext context, AnnotatedTypeMetadata 
metadata) {
-        boolean isReadModeEnabled = 
Optional.ofNullable(context.getEnvironment().getProperty("fineract.mode.read-enabled",
 Boolean.class))
+        boolean isReadModeEnabled = Optional.ofNullable(
+                
context.getEnvironment().getProperty(FineractInstanceModeConstants.FINERACT_MODE_READ_ENABLE_PROPERTY,
 Boolean.class))
                 .orElse(true);
-        boolean isWriteModeEnabled = 
Optional.ofNullable(context.getEnvironment().getProperty("fineract.mode.write-enabled",
 Boolean.class))
+        boolean isWriteModeEnabled = Optional.ofNullable(
+                
context.getEnvironment().getProperty(FineractInstanceModeConstants.FINERACT_MODE_WRITE_ENABLE_PROPERTY,
 Boolean.class))
                 .orElse(true);
-        boolean isBatchModeEnabled = 
Optional.ofNullable(context.getEnvironment().getProperty("fineract.mode.batch-enabled",
 Boolean.class))
+        boolean isBatchModeEnabled = Optional.ofNullable(
+                
context.getEnvironment().getProperty(FineractInstanceModeConstants.FINERACT_MODE_BATCH_ENABLE_PROPERTY,
 Boolean.class))
                 .orElse(true);
-        return !isReadModeEnabled && (isWriteModeEnabled || 
isBatchModeEnabled);
+        return (isReadModeEnabled && isBatchModeEnabled && isWriteModeEnabled) 
// All mode
+                || (!isReadModeEnabled && !isBatchModeEnabled && 
isWriteModeEnabled); // Write mode
     }
 }
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/EnableFineractEventsCondition.java
 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/EnableFineractEventsCondition.java
index 1c3f6710d..6eea73713 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/EnableFineractEventsCondition.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/EnableFineractEventsCondition.java
@@ -19,6 +19,7 @@
 package org.apache.fineract.infrastructure.core.config;
 
 import java.util.Optional;
+import 
org.apache.fineract.infrastructure.instancemode.api.FineractInstanceModeConstants;
 import org.springframework.context.annotation.Condition;
 import org.springframework.context.annotation.ConditionContext;
 import org.springframework.core.type.AnnotatedTypeMetadata;
@@ -27,11 +28,14 @@ public class EnableFineractEventsCondition implements 
Condition {
 
     @Override
     public boolean matches(ConditionContext context, AnnotatedTypeMetadata 
metadata) {
-        boolean isReadModeEnabled = 
Optional.ofNullable(context.getEnvironment().getProperty("fineract.mode.read-enabled",
 Boolean.class))
+        boolean isReadModeEnabled = Optional.ofNullable(
+                
context.getEnvironment().getProperty(FineractInstanceModeConstants.FINERACT_MODE_READ_ENABLE_PROPERTY,
 Boolean.class))
                 .orElse(true);
-        boolean isWriteModeEnabled = 
Optional.ofNullable(context.getEnvironment().getProperty("fineract.mode.write-enabled",
 Boolean.class))
+        boolean isWriteModeEnabled = Optional.ofNullable(
+                
context.getEnvironment().getProperty(FineractInstanceModeConstants.FINERACT_MODE_WRITE_ENABLE_PROPERTY,
 Boolean.class))
                 .orElse(true);
-        boolean isBatchModeEnabled = 
Optional.ofNullable(context.getEnvironment().getProperty("fineract.mode.batch-enabled",
 Boolean.class))
+        boolean isBatchModeEnabled = Optional.ofNullable(
+                
context.getEnvironment().getProperty(FineractInstanceModeConstants.FINERACT_MODE_BATCH_ENABLE_PROPERTY,
 Boolean.class))
                 .orElse(true);
         return !isReadModeEnabled && (isWriteModeEnabled || 
isBatchModeEnabled);
     }
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/instancemode/api/FineractInstanceModeConstants.java
 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/instancemode/api/FineractInstanceModeConstants.java
new file mode 100644
index 000000000..73f0865f9
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/instancemode/api/FineractInstanceModeConstants.java
@@ -0,0 +1,31 @@
+/**
+ * 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.fineract.infrastructure.instancemode.api;
+
+public final class FineractInstanceModeConstants {
+
+    private FineractInstanceModeConstants() {
+
+    }
+
+    public static final String FINERACT_MODE_READ_ENABLE_PROPERTY = 
"fineract.mode.read-enabled";
+    public static final String FINERACT_MODE_WRITE_ENABLE_PROPERTY = 
"fineract.mode.write-enabled";
+    public static final String FINERACT_MODE_BATCH_ENABLE_PROPERTY = 
"fineract.mode.batch-enabled";
+
+}
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/notification/eventandlistener/ActiveMQNotificationEventListener.java
 
b/fineract-provider/src/main/java/org/apache/fineract/notification/eventandlistener/ActiveMQNotificationEventListener.java
index f19f3e513..e8f47f683 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/notification/eventandlistener/ActiveMQNotificationEventListener.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/notification/eventandlistener/ActiveMQNotificationEventListener.java
@@ -23,7 +23,7 @@ import javax.jms.Message;
 import javax.jms.ObjectMessage;
 import javax.jms.Session;
 import lombok.RequiredArgsConstructor;
-import 
org.apache.fineract.infrastructure.core.config.EnableFineractEventsCondition;
+import 
org.apache.fineract.infrastructure.core.config.EnableFineractEventListenerCondition;
 import org.apache.fineract.notification.data.NotificationData;
 import org.springframework.context.annotation.Conditional;
 import org.springframework.context.annotation.Profile;
@@ -32,7 +32,7 @@ import org.springframework.stereotype.Component;
 
 @Component
 @Profile("activeMqEnabled")
-@Conditional(EnableFineractEventsCondition.class)
+@Conditional(EnableFineractEventListenerCondition.class)
 @RequiredArgsConstructor
 public class ActiveMQNotificationEventListener implements 
SessionAwareMessageListener {
 
diff --git 
a/fineract-provider/src/test/java/org/apache/fineract/infrastructure/core/config/EnableFineractEventListenerConditionTest.java
 
b/fineract-provider/src/test/java/org/apache/fineract/infrastructure/core/config/EnableFineractEventListenerConditionTest.java
new file mode 100644
index 000000000..160549236
--- /dev/null
+++ 
b/fineract-provider/src/test/java/org/apache/fineract/infrastructure/core/config/EnableFineractEventListenerConditionTest.java
@@ -0,0 +1,102 @@
+/**
+ * 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.fineract.infrastructure.core.config;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.mock;
+
+import 
org.apache.fineract.infrastructure.instancemode.api.FineractInstanceModeConstants;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.env.Environment;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.LENIENT)
+public class EnableFineractEventListenerConditionTest {
+
+    @InjectMocks
+    private EnableFineractEventListenerCondition underTest;
+
+    @Mock
+    private AnnotatedTypeMetadata metadata;
+
+    private ConditionContext context;
+    private Environment environment;
+
+    @BeforeEach
+    void setUp() {
+        context = mock(ConditionContext.class);
+        environment = mock(Environment.class);
+    }
+
+    @Test
+    void testOnMessage_ShouldBlockOnMessage_WhenFineractIsInBatchMode() {
+
+        
given(environment.getProperty(FineractInstanceModeConstants.FINERACT_MODE_READ_ENABLE_PROPERTY,
 Boolean.class)).willReturn(false);
+        
given(environment.getProperty(FineractInstanceModeConstants.FINERACT_MODE_WRITE_ENABLE_PROPERTY,
 Boolean.class)).willReturn(false);
+        
given(environment.getProperty(FineractInstanceModeConstants.FINERACT_MODE_BATCH_ENABLE_PROPERTY,
 Boolean.class)).willReturn(true);
+        given(context.getEnvironment()).willReturn(environment);
+
+        assertFalse(underTest.matches(context, metadata));
+    }
+
+    @Test
+    void testOnMessage_ShouldAllowOnMessage_WhenFineractIsInAllMode() {
+
+        
given(environment.getProperty(FineractInstanceModeConstants.FINERACT_MODE_READ_ENABLE_PROPERTY,
 Boolean.class)).willReturn(true);
+        
given(environment.getProperty(FineractInstanceModeConstants.FINERACT_MODE_WRITE_ENABLE_PROPERTY,
 Boolean.class)).willReturn(true);
+        
given(environment.getProperty(FineractInstanceModeConstants.FINERACT_MODE_BATCH_ENABLE_PROPERTY,
 Boolean.class)).willReturn(true);
+        given(context.getEnvironment()).willReturn(environment);
+
+        assertTrue(underTest.matches(context, metadata));
+    }
+
+    @Test
+    void testOnMessage_ShouldAllowOnMessage_WhenFineractIsInWriteMode() {
+
+        
given(environment.getProperty(FineractInstanceModeConstants.FINERACT_MODE_READ_ENABLE_PROPERTY,
 Boolean.class)).willReturn(false);
+        
given(environment.getProperty(FineractInstanceModeConstants.FINERACT_MODE_WRITE_ENABLE_PROPERTY,
 Boolean.class)).willReturn(true);
+        
given(environment.getProperty(FineractInstanceModeConstants.FINERACT_MODE_BATCH_ENABLE_PROPERTY,
 Boolean.class)).willReturn(false);
+        given(context.getEnvironment()).willReturn(environment);
+
+        assertTrue(underTest.matches(context, metadata));
+    }
+
+    @Test
+    void testOnMessage_ShouldBlockOnMessage_WhenFineractIsInReadMode() {
+
+        
given(environment.getProperty(FineractInstanceModeConstants.FINERACT_MODE_READ_ENABLE_PROPERTY,
 Boolean.class)).willReturn(true);
+        
given(environment.getProperty(FineractInstanceModeConstants.FINERACT_MODE_WRITE_ENABLE_PROPERTY,
 Boolean.class)).willReturn(false);
+        
given(environment.getProperty(FineractInstanceModeConstants.FINERACT_MODE_BATCH_ENABLE_PROPERTY,
 Boolean.class)).willReturn(false);
+        given(context.getEnvironment()).willReturn(environment);
+
+        assertFalse(underTest.matches(context, metadata));
+    }
+
+}
diff --git 
a/fineract-provider/src/test/java/org/apache/fineract/infrastructure/instancemode/InstanceModeMock.java
 
b/fineract-provider/src/test/java/org/apache/fineract/infrastructure/instancemode/InstanceModeMock.java
new file mode 100644
index 000000000..99c9a3104
--- /dev/null
+++ 
b/fineract-provider/src/test/java/org/apache/fineract/infrastructure/instancemode/InstanceModeMock.java
@@ -0,0 +1,37 @@
+/**
+ * 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.fineract.infrastructure.instancemode;
+
+import org.apache.fineract.infrastructure.core.config.FineractProperties;
+
+public final class InstanceModeMock {
+
+    private InstanceModeMock() {
+
+    }
+
+    public static FineractProperties.FineractModeProperties 
createModeProps(boolean readEnabled, boolean writeEnabled,
+            boolean batchEnabled) {
+        FineractProperties.FineractModeProperties modeProperties = new 
FineractProperties.FineractModeProperties();
+        modeProperties.setReadEnabled(readEnabled);
+        modeProperties.setWriteEnabled(writeEnabled);
+        modeProperties.setBatchEnabled(batchEnabled);
+        return modeProperties;
+    }
+}
diff --git 
a/fineract-provider/src/test/java/org/apache/fineract/infrastructure/instancemode/filter/FineractInstanceModeApiFilterTest.java
 
b/fineract-provider/src/test/java/org/apache/fineract/infrastructure/instancemode/filter/FineractInstanceModeApiFilterTest.java
index a6715d6d9..dff915d69 100644
--- 
a/fineract-provider/src/test/java/org/apache/fineract/infrastructure/instancemode/filter/FineractInstanceModeApiFilterTest.java
+++ 
b/fineract-provider/src/test/java/org/apache/fineract/infrastructure/instancemode/filter/FineractInstanceModeApiFilterTest.java
@@ -29,6 +29,7 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import org.apache.fineract.infrastructure.core.config.FineractProperties;
+import org.apache.fineract.infrastructure.instancemode.InstanceModeMock;
 import org.apache.hc.core5.http.HttpStatus;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -70,7 +71,7 @@ class FineractInstanceModeApiFilterTest {
     @Test
     void 
testDoFilterInternal_ShouldLetReadApisThrough_WhenFineractIsInAllModeAndIsGetApi()
 throws ServletException, IOException {
         // given
-        FineractProperties.FineractModeProperties modeProperties = 
createModeProps(true, true, true);
+        FineractProperties.FineractModeProperties modeProperties = 
InstanceModeMock.createModeProps(true, true, true);
         given(fineractProperties.getMode()).willReturn(modeProperties);
         given(request.getMethod()).willReturn(HttpMethod.GET.name());
         given(request.getPathInfo()).willReturn("/loans");
@@ -83,7 +84,7 @@ class FineractInstanceModeApiFilterTest {
     @Test
     void 
testDoFilterInternal_ShouldLetReadApisThrough_WhenFineractIsInReadOnlyModeAndIsGetApi()
 throws ServletException, IOException {
         // given
-        FineractProperties.FineractModeProperties modeProperties = 
createModeProps(true, false, false);
+        FineractProperties.FineractModeProperties modeProperties = 
InstanceModeMock.createModeProps(true, false, false);
         given(fineractProperties.getMode()).willReturn(modeProperties);
         given(request.getMethod()).willReturn(HttpMethod.GET.name());
         given(request.getPathInfo()).willReturn("/loans");
@@ -97,7 +98,7 @@ class FineractInstanceModeApiFilterTest {
     void 
testDoFilterInternal_ShouldLetActuatorApisThrough_WhenFineractIsInReadOnlyModeAndIsHealthApi()
             throws ServletException, IOException {
         // given
-        FineractProperties.FineractModeProperties modeProperties = 
createModeProps(true, false, false);
+        FineractProperties.FineractModeProperties modeProperties = 
InstanceModeMock.createModeProps(true, false, false);
         given(fineractProperties.getMode()).willReturn(modeProperties);
         given(request.getMethod()).willReturn(HttpMethod.GET.name());
         given(request.getServletPath()).willReturn("/actuator/health");
@@ -111,7 +112,7 @@ class FineractInstanceModeApiFilterTest {
     @Test
     void 
testDoFilterInternal_ShouldNotLetWriteApisThrough_WhenFineractIsInReadOnlyModeAndIsPostApi()
 throws ServletException, IOException {
         // given
-        FineractProperties.FineractModeProperties modeProperties = 
createModeProps(true, false, false);
+        FineractProperties.FineractModeProperties modeProperties = 
InstanceModeMock.createModeProps(true, false, false);
         given(fineractProperties.getMode()).willReturn(modeProperties);
         given(request.getMethod()).willReturn(HttpMethod.POST.name());
         given(request.getPathInfo()).willReturn("/loans");
@@ -125,7 +126,7 @@ class FineractInstanceModeApiFilterTest {
     @Test
     void 
testDoFilterInternal_ShouldNotLetBatchApisThrough_WhenFineractIsInReadOnlyModeAndIsJobsApi()
 throws ServletException, IOException {
         // given
-        FineractProperties.FineractModeProperties modeProperties = 
createModeProps(true, false, false);
+        FineractProperties.FineractModeProperties modeProperties = 
InstanceModeMock.createModeProps(true, false, false);
         given(fineractProperties.getMode()).willReturn(modeProperties);
         given(request.getMethod()).willReturn(HttpMethod.POST.name());
         given(request.getPathInfo()).willReturn("/jobs/1");
@@ -139,7 +140,7 @@ class FineractInstanceModeApiFilterTest {
     @Test
     void 
testDoFilterInternal_ShouldLetReadApisThrough_WhenFineractIsInWriteModeAndIsGetApi()
 throws ServletException, IOException {
         // given
-        FineractProperties.FineractModeProperties modeProperties = 
createModeProps(false, true, false);
+        FineractProperties.FineractModeProperties modeProperties = 
InstanceModeMock.createModeProps(false, true, false);
         given(fineractProperties.getMode()).willReturn(modeProperties);
         given(request.getMethod()).willReturn(HttpMethod.GET.name());
         given(request.getPathInfo()).willReturn("/loans");
@@ -152,7 +153,7 @@ class FineractInstanceModeApiFilterTest {
     @Test
     void 
testDoFilterInternal_ShouldLetWriteApisThrough_WhenFineractIsInWriteModeAndIsPostApi()
 throws ServletException, IOException {
         // given
-        FineractProperties.FineractModeProperties modeProperties = 
createModeProps(false, true, false);
+        FineractProperties.FineractModeProperties modeProperties = 
InstanceModeMock.createModeProps(false, true, false);
         given(fineractProperties.getMode()).willReturn(modeProperties);
         given(request.getMethod()).willReturn(HttpMethod.POST.name());
         given(request.getPathInfo()).willReturn("/loans");
@@ -165,7 +166,7 @@ class FineractInstanceModeApiFilterTest {
     @Test
     void 
testDoFilterInternal_ShouldLetWriteApisThrough_WhenFineractIsInWriteModeAndIsPutApi()
 throws ServletException, IOException {
         // given
-        FineractProperties.FineractModeProperties modeProperties = 
createModeProps(false, true, false);
+        FineractProperties.FineractModeProperties modeProperties = 
InstanceModeMock.createModeProps(false, true, false);
         given(fineractProperties.getMode()).willReturn(modeProperties);
         given(request.getMethod()).willReturn(HttpMethod.PUT.name());
         given(request.getPathInfo()).willReturn("/loans/1");
@@ -178,7 +179,7 @@ class FineractInstanceModeApiFilterTest {
     @Test
     void 
testDoFilterInternal_ShouldLetActuatorApisThrough_WhenFineractIsInWriteModeAndIsHelathApi()
 throws ServletException, IOException {
         // given
-        FineractProperties.FineractModeProperties modeProperties = 
createModeProps(false, true, false);
+        FineractProperties.FineractModeProperties modeProperties = 
InstanceModeMock.createModeProps(false, true, false);
         given(fineractProperties.getMode()).willReturn(modeProperties);
         given(request.getMethod()).willReturn(HttpMethod.GET.name());
         given(request.getServletPath()).willReturn("/actuator/health");
@@ -192,7 +193,7 @@ class FineractInstanceModeApiFilterTest {
     @Test
     void 
testDoFilterInternal_ShouldNotLetBatchApisThrough_WhenFineractIsInWriteModeAndIsJobsApi()
 throws ServletException, IOException {
         // given
-        FineractProperties.FineractModeProperties modeProperties = 
createModeProps(false, true, false);
+        FineractProperties.FineractModeProperties modeProperties = 
InstanceModeMock.createModeProps(false, true, false);
         given(fineractProperties.getMode()).willReturn(modeProperties);
         given(request.getMethod()).willReturn(HttpMethod.POST.name());
         given(request.getPathInfo()).willReturn("/jobs/1");
@@ -206,7 +207,7 @@ class FineractInstanceModeApiFilterTest {
     @Test
     void 
testDoFilterInternal_ShouldLetBatchApisThrough_WhenFineractIsInBatchModeAndIsJobsApi()
 throws ServletException, IOException {
         // given
-        FineractProperties.FineractModeProperties modeProperties = 
createModeProps(false, false, true);
+        FineractProperties.FineractModeProperties modeProperties = 
InstanceModeMock.createModeProps(false, false, true);
         given(fineractProperties.getMode()).willReturn(modeProperties);
         given(request.getMethod()).willReturn(HttpMethod.POST.name());
         given(request.getPathInfo()).willReturn("/jobs/1");
@@ -220,7 +221,7 @@ class FineractInstanceModeApiFilterTest {
     void 
testDoFilterInternal_ShouldLetBatchApisThrough_WhenFineractIsInBatchModeAndIsListingJobsApi()
             throws ServletException, IOException {
         // given
-        FineractProperties.FineractModeProperties modeProperties = 
createModeProps(false, false, true);
+        FineractProperties.FineractModeProperties modeProperties = 
InstanceModeMock.createModeProps(false, false, true);
         given(fineractProperties.getMode()).willReturn(modeProperties);
         given(request.getMethod()).willReturn(HttpMethod.GET.name());
         given(request.getPathInfo()).willReturn("/jobs");
@@ -233,7 +234,7 @@ class FineractInstanceModeApiFilterTest {
     @Test
     void 
testDoFilterInternal_ShouldLetActuatorApisThrough_WhenFineractIsInBatchModeAndIsHealthApi()
 throws ServletException, IOException {
         // given
-        FineractProperties.FineractModeProperties modeProperties = 
createModeProps(false, false, true);
+        FineractProperties.FineractModeProperties modeProperties = 
InstanceModeMock.createModeProps(false, false, true);
         given(fineractProperties.getMode()).willReturn(modeProperties);
         given(request.getMethod()).willReturn(HttpMethod.GET.name());
         given(request.getServletPath()).willReturn("/actuator/health");
@@ -243,12 +244,4 @@ class FineractInstanceModeApiFilterTest {
         // then
         verify(filterChain).doFilter(request, response);
     }
-
-    private FineractProperties.FineractModeProperties createModeProps(boolean 
readEnabled, boolean writeEnabled, boolean batchEnabled) {
-        FineractProperties.FineractModeProperties modeProperties = new 
FineractProperties.FineractModeProperties();
-        modeProperties.setReadEnabled(readEnabled);
-        modeProperties.setWriteEnabled(writeEnabled);
-        modeProperties.setBatchEnabled(batchEnabled);
-        return modeProperties;
-    }
 }

Reply via email to