-
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.
Merge pull request #10 from OpenConext/develop
Prepare release 2.3.0
- Loading branch information
Showing
15 changed files
with
184 additions
and
131 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
36 changes: 36 additions & 0 deletions
36
...-notificatie/src/main/java/nl/kennisnet/services/actuator/ReleaseDaysInfoContributor.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,36 @@ | ||
package nl.kennisnet.services.actuator; | ||
|
||
import org.springframework.boot.actuate.info.Info; | ||
import org.springframework.boot.actuate.info.InfoContributor; | ||
import org.springframework.boot.info.BuildProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.Instant; | ||
import java.time.LocalDate; | ||
import java.time.ZoneId; | ||
import java.time.temporal.ChronoUnit; | ||
|
||
@Component | ||
public class ReleaseDaysInfoContributor implements InfoContributor { | ||
|
||
private static final String RELEASE_DAYS_KEY = "days_since_release"; | ||
|
||
private final BuildProperties buildProperties; | ||
|
||
public ReleaseDaysInfoContributor(BuildProperties buildProperties) { | ||
this.buildProperties = buildProperties; | ||
} | ||
|
||
@Override | ||
public void contribute(Info.Builder builder) { | ||
long currentDays = 0L; | ||
|
||
if (null != buildProperties.getTime()) { | ||
LocalDate releaseDate = LocalDate.ofInstant(buildProperties.getTime(), ZoneId.systemDefault()); | ||
LocalDate currentDate = LocalDate.ofInstant(Instant.now(), ZoneId.systemDefault()); | ||
currentDays = ChronoUnit.DAYS.between(releaseDate, currentDate); | ||
} | ||
builder.withDetail(RELEASE_DAYS_KEY, currentDays); | ||
} | ||
|
||
} |
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
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
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
10 changes: 0 additions & 10 deletions
10
...-notificatie/src/main/java/nl/kennisnet/services/web/exception/NoMatchFoundException.java
This file was deleted.
Oops, something went wrong.
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
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
56 changes: 56 additions & 0 deletions
56
...atie/src/test/java/nl/kennisnet/services/web/actuator/ReleaseDaysInfoContributorTest.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,56 @@ | ||
package nl.kennisnet.services.web.actuator; | ||
|
||
import nl.kennisnet.services.actuator.ReleaseDaysInfoContributor; | ||
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.springframework.boot.actuate.info.Info; | ||
import org.springframework.boot.info.BuildProperties; | ||
|
||
import java.time.Duration; | ||
import java.time.Instant; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class ReleaseDaysInfoContributorTest { | ||
|
||
@Mock | ||
private BuildProperties buildProperties; | ||
|
||
@InjectMocks | ||
private ReleaseDaysInfoContributor infoIndicator; | ||
|
||
@Test | ||
void testSeveralDays() { | ||
when(buildProperties.getTime()).thenReturn(Instant.now().minus(Duration.ofDays(3))); | ||
Info.Builder builder = new Info.Builder(); | ||
infoIndicator.contribute(builder); | ||
Info info = builder.build(); | ||
|
||
assertEquals(3L, info.get("days_since_release")); | ||
} | ||
|
||
@Test | ||
void testZeroDays() { | ||
when(buildProperties.getTime()).thenReturn(Instant.now()); | ||
Info.Builder builder = new Info.Builder(); | ||
infoIndicator.contribute(builder); | ||
Info info = builder.build(); | ||
|
||
assertEquals(0L, info.get("days_since_release")); | ||
} | ||
|
||
@Test | ||
void testNoBuildInfo() { | ||
Info.Builder builder = new Info.Builder(); | ||
infoIndicator.contribute(builder); | ||
Info info = builder.build(); | ||
|
||
assertEquals(0L, info.get("days_since_release")); | ||
} | ||
|
||
} |
Oops, something went wrong.