Skip to content

Commit

Permalink
Merge 2046362 into 0169b7a
Browse files Browse the repository at this point in the history
  • Loading branch information
sanintel3 committed Jan 11, 2023
2 parents 0169b7a + 2046362 commit 01d878b
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file, which follo
on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to
[Semantic Versioning](http://semver.org/).

## [11.0.0-M31] - 2023-01-10
### Changed
- Provide constant for artemis healthcheck name
- Provide capability to override destination names while performing artemis healthcheck
- Update framework version to 11.0.0-M30

## [11.0.0-M30] - 2022-11-29
### Changed
- Update framework version to 11.0.0-M29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

public class ArtemisHealthcheck implements Healthcheck {

public static final String ARTEMIS_HEALTHCHECK_NAME = "artemis-healthcheck";

@Inject
private Logger logger;

Expand All @@ -21,7 +23,7 @@ public class ArtemisHealthcheck implements Healthcheck {

@Override
public String getHealthcheckName() {
return "artemis-healthcheck";
return ARTEMIS_HEALTHCHECK_NAME;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package uk.gov.justice.services.healthcheck.healthchecks.artemis;

import javax.inject.Inject;
import java.util.List;
import java.util.stream.Collectors;

public class DefaultDestinationNamesProvider implements DestinationNamesProvider {

private static final List<String> DESTINATION_NAME_PATTERNS = List.of("%s.controller.command", "%s.handler.command", "%s.event");

@Inject
private JndiContextNameProvider jndiContextNameProvider;

public List<String> getDestinationNames() {
return DESTINATION_NAME_PATTERNS.stream()
.map(qp -> String.format(qp, getContextName()))
.collect(Collectors.toList());
}

protected final String getContextName() {
return jndiContextNameProvider.getContextName();
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
package uk.gov.justice.services.healthcheck.healthchecks.artemis;

import javax.inject.Inject;
import java.util.List;
import java.util.stream.Collectors;

public class DestinationNamesProvider {

private static final List<String> DESTINATION_NAME_PATTERNS = List.of("%s.controller.command", "%s.handler.command", "%s.event");

@Inject
private JndiContextNameProvider jndiContextNameProvider;

public List<String> getDestinationNames() {
var contextName = jndiContextNameProvider.getContextName();
return DESTINATION_NAME_PATTERNS.stream()
.map(qp -> String.format(qp, contextName))
.collect(Collectors.toList());
}
public interface DestinationNamesProvider {
List<String> getDestinationNames();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
import org.mockito.runners.MockitoJUnitRunner;

import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.BDDMockito.given;

@RunWith(MockitoJUnitRunner.class)
public class DestinationNamesProviderTest {
public class DefaultDestinationNamesProviderTest {

@Mock
private JndiContextNameProvider jndiContextNameProvider;

@InjectMocks
private DestinationNamesProvider destinationNamesProvider;
private DefaultDestinationNamesProvider destinationNamesProvider;

@Test
public void shouldReturnContextSpecificCQRSDestinationNames() {
Expand All @@ -26,6 +27,13 @@ public void shouldReturnContextSpecificCQRSDestinationNames() {
assertThat(destinationNamesProvider.getDestinationNames(), hasItems("people.controller.command",
"people.handler.command",
"people.event"));
}

@Test
public void shouldReturnContextNae() {
given(jndiContextNameProvider.getContextName()).willReturn("people");

assertThat(destinationNamesProvider.getContextName(), is("people"));

}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<properties>
<cpp.repo.name>event-store</cpp.repo.name>
<framework.version>11.0.0-M29</framework.version>
<framework.version>11.0.0-M30</framework.version>
</properties>

<dependencyManagement>
Expand Down

0 comments on commit 01d878b

Please sign in to comment.