-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JNDI value to enable/disable event catchup
- Loading branch information
amckenzie
committed
Jan 22, 2019
1 parent
491a408
commit 16431da
Showing
5 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
.../java/uk/gov/justice/services/event/sourcing/subscription/startup/EventCatchupConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package uk.gov.justice.services.event.sourcing.subscription.startup; | ||
|
||
import static java.lang.Boolean.valueOf; | ||
|
||
import uk.gov.justice.services.common.configuration.Value; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class EventCatchupConfig { | ||
|
||
@Inject | ||
@Value(key = "event.catchup.enabled", defaultValue = "false") | ||
String eventCatchupEnabled; | ||
|
||
public boolean isEventCatchupEnabled() { | ||
return valueOf(eventCatchupEnabled); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...a/uk/gov/justice/services/event/sourcing/subscription/startup/EventCatchupConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package uk.gov.justice.services.event.sourcing.subscription.startup; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import org.junit.Test; | ||
import org.mockito.InjectMocks; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class EventCatchupConfigTest { | ||
|
||
@InjectMocks | ||
private EventCatchupConfig eventCatchupConfig; | ||
|
||
@Test | ||
public void shouldReturnTrueIfEventCatchupSetToTrue() throws Exception { | ||
|
||
eventCatchupConfig.eventCatchupEnabled = "true"; | ||
|
||
assertThat(eventCatchupConfig.isEventCatchupEnabled(), is(true)); | ||
} | ||
|
||
@Test | ||
public void shouldReturnFalseIfEventCatchupSetToFalse() throws Exception { | ||
|
||
eventCatchupConfig.eventCatchupEnabled = "false"; | ||
|
||
assertThat(eventCatchupConfig.isEventCatchupEnabled(), is(false)); | ||
} | ||
|
||
@Test | ||
public void shouldReturnFalseIfEventCatchupSetToSometingRandom() throws Exception { | ||
|
||
eventCatchupConfig.eventCatchupEnabled = "something silly"; | ||
|
||
assertThat(eventCatchupConfig.isEventCatchupEnabled(), is(false)); | ||
} | ||
|
||
@Test | ||
public void shouldBeCaseInsensitive() throws Exception { | ||
|
||
eventCatchupConfig.eventCatchupEnabled = "TrUe"; | ||
|
||
assertThat(eventCatchupConfig.isEventCatchupEnabled(), is(true)); | ||
} | ||
|
||
@Test | ||
public void shouldBeFalseIfNull() throws Exception { | ||
|
||
eventCatchupConfig.eventCatchupEnabled = null; | ||
|
||
assertThat(eventCatchupConfig.isEventCatchupEnabled(), is(false)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters