update to Java 13, fixing build

This commit is contained in:
Tom Hombergs
2020-05-27 06:33:15 +10:00
parent 381fe85e39
commit 97bf254d85
14 changed files with 62 additions and 51 deletions

View File

@@ -4,16 +4,16 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorldController {
class HelloWorldController {
private final UserRepository userRepository;
public HelloWorldController(UserRepository userRepository) {
HelloWorldController(UserRepository userRepository) {
this.userRepository = userRepository;
}
@GetMapping("/hello")
public String helloWorld(){
String helloWorld(){
Iterable<User> users = userRepository.findAll();

View File

@@ -25,6 +25,7 @@ Resources:
SecretStringTemplate: !Join ['', ['{"username": "', !Ref 'DBUsername' ,'"}']]
GenerateStringKey: "password"
PasswordLength: 32
ExcludeCharacters: '"@/\'
DBSubnetGroup:
Type: AWS::RDS::DBSubnetGroup
@@ -75,6 +76,11 @@ Outputs:
Value: !GetAtt 'PostgresInstance.Endpoint.Port'
Export:
Name: !Join [ ':', [ !Ref 'AWS::StackName', 'EndpointPort' ] ]
DBName:
Description: The name of the database that is created within the PostgreSQL instance.
Value: !Ref DBName
Export:
Name: !Join [ ':', [ !Ref 'AWS::StackName', 'DBName' ] ]
Secret:
Description: Reference to the secret containing the password to the database.
Value: !Ref 'Secret'

View File

@@ -1 +1 @@
<mxfile modified="2020-05-09T20:36:37.901Z" host="app.diagrams.net" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" etag="mEDUT6Ftvnc8aD1Huwrz" version="13.0.5" type="device"><diagram id="Ht1M8jgEwFfnCIfOTk4-" name="Page-1">7VpZb9s4EP41fqyhW/JjfKUBWqyx3t22TwYtMTIRWXRp+sqv36FEXaR8pHESGIhhIJohRQ5nvm84pNOxB8v9PUOrxXca4aRjGdG+Yw87lmXargt/hOaQa3zfyRUxI5HsVCmm5BlLpSG1GxLhdaMjpzThZNVUhjRNccgbOsQY3TW7PdKkOesKxVhTTEOU6NofJOILqT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78EgJU2VIc7uuNw0NdmmBGwI8CWqeLxRwkp/woKQvrijE/n/aFT08Cpl7KGDL6DCewo26bdzFtkJDDTcTpqgJfr4k9KJuaI+SLlC/Vr06Uccr6Vw5kGwo6cydoA2UALZf4Csx6n5i9ALNnoeh+HBQt41pYVI4CtvnOWGwr424Ki3vCfxZzw3MNiSBVQBTCoSZcL3W6F8K193FwtY1eE64GnCPtP0OsU/wGUCDWMbpG7WNehF+IvSj3y27yIu34Cpx2wh2z8kx/eMgtuC6Z9Lr31JnoJo861ssPOeVPJdX1WvHji32l87FalfptRyC/13X10tR1Xl+a7pPNeIb/2n51Dr9+8/m/z/h+88XUwDBhZAsnxc/r5M/r5I+9TtaY1cK/o2Rzex98ndzKNut86v17KO4gHlIoPlJxv3xTCZhFax0z1si3s9/mTl4vvSranuM0o+07ZRDrudXS4x2cqFNeFetbP/O3FoJ/Vny2HNuP0+N9ak1TqTUtp7yrfnGtqWzs2Vi92kcZ98XF5uXHKRCrf+7Iu1f/ImOP/gc=</diagram></mxfile>
<mxfile modified="2020-05-11T21:18:00.281Z" host="app.diagrams.net" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" etag="d22WT4Cb11cg7E6o-Mdr" version="13.0.9" type="device"><diagram id="Ht1M8jgEwFfnCIfOTk4-" name="Page-1">7VvZcuI4FP0aHpuyJK+PYUk6VemaTNHTyxNlsGI8MRYtiy1fP5KRwZbEkkBI00OKqljXspZ7z7mLDA3UHi/uaDgZfSERThvQihYN1GlACJDj8H9CslxJPM9eCWKaRLLTRtBLXrAUWlI6TSKc1zoyQlKWTOrCIckyPGQ1WUgpmde7PZG0PuskjLEm6A3DVJd+TyI2klLgBpsbn3ESj+TUPvRWN8Zh2VnuJB+FEZlXRKjbQG1KCFtdjRdtnArllXpZPXe75e56YRRn7JAHHuJp6+UXX9i3PB/cv7TDr5/+/SRHmYXpVG74cTpIk6FY73SQYSbXzpalQiYkyVihVK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iLbsT7Q2HclAyfhSgdFO3SxgVsQsrKfpLI/MnbJF17Cy0psZ2WK2DKE84sWiOL24Iuf1QbP0WD59ey2VlUb3aW1dYjpgnXo4DW7jRxBZJdepSU5fuKMdvv84VOdwKmmsSUR8gUpzyczuqvWE2QkMM9irpqAz6lgIeBq+Wlq33K56ovRZWhgFJ2Il/PcVeq0MYqYLre6BHIda/IPQC5ewHpfBwgoXVCRCrVAArOj0hTPndJiHw7iIKPAxGyAhVEb0OQXX7npkSQbTWtyh84CEzcECIJX3eTZ1vblw81DuxcpdYfOAqWVys4LbL1hHRXpXKRBQh8femx/mrS5sSr/LITOlHVqhYmgZ4uBk3D8a5jH58wGl9vwf1I4NZiMcW9vx94x/uM+6dMHERdFCxolOt4gF0PFV8aeL9S1LXtmsWBZ6/DWNXoUDe5v8N1HmXySy8Rtpplb1ZvSOp3keJDwh9Qwh+0m77/tgjoAnNsOXXMc3bHsNf2PzrmGd8s6qi/nsH8LmcwR70yVc9gkGs3TXH1nY5hjGC7+Fp2kbAf5dz8ulLJ8tamkBWNZaVhLmMVP/o23+3ovns7zz/EVSPrrZWK6g8PLHTPXZvY1hn8tP4C9MKoc/pjoNfyZ1f8Oyz3OQt/7KBekEOVBE0L2bYPPcd3oeW9MQdybGVYHh38wHUc4PHQgdR3PqdKidz6bhTq7O2/L4VS64ojUyje3PwCZ9V98zsm1P0P</diagram></mxfile>

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -9,12 +9,6 @@ Parameters:
DatabaseStackName:
Type: String
Description: The name of the database stack with the database this service should connect to.
DBName:
Type: String
Description: The database name.
DBUsername:
Type: String
Description: The database username.
ServiceName:
Type: String
Description: A human-readable name for the service.
@@ -117,9 +111,13 @@ Resources:
- ':'
- Fn::ImportValue: !Join [':', [!Ref 'DatabaseStackName', 'EndpointPort']]
- '/'
- !Ref 'DBName'
- Fn::ImportValue: !Join [':', [!Ref 'DatabaseStackName', 'DBName']]
- Name: SPRING_DATASOURCE_USERNAME
Value: !Ref 'DBUsername'
Value: !Join
- ''
- - '{{resolve:secretsmanager:'
- Fn::ImportValue: !Join [':', [!Ref 'DatabaseStackName', 'Secret']]
- ':SecretString:username}}'
- Name: SPRING_DATASOURCE_PASSWORD
Value: !Join
- ''

View File

@@ -1,5 +1,5 @@
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'org.springframework.boot' version '2.3.0.RELEASE'
id 'java'
}
@@ -7,7 +7,7 @@ apply plugin: 'io.spring.dependency-management'
group = 'io.reflectoring'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
sourceCompatibility = '13'
repositories {
mavenCentral()
@@ -23,6 +23,7 @@ dependencies {
testImplementation('org.junit.jupiter:junit-jupiter:5.4.0')
testImplementation('org.springframework.boot:spring-boot-starter-test'){
exclude group: 'junit', module: 'junit'
exclude group: 'org.junit.vintage'
}
}

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0
spring-boot/configuration/gradlew vendored Normal file → Executable file
View File

View File

@@ -0,0 +1,14 @@
package io.reflectoring;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.PropertySource;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -1,5 +1,4 @@
myapp.mail.enabled=true
myapp
myapp.mail.pauseBetweenMails=5s
myapp.mail.maxAttachmentSize=1MB
myapp.mail.smtpServers[0]=server1

View File

@@ -1,37 +1,36 @@
package io.reflectoring.configuration.mail;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.unit.DataSize;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.util.unit.DataSize;
import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(properties = {
"myapp.mail.enabled=asd",
"myapp.mail.defaultSubject=hello",
"myapp.mail.pauseBetweenMails=5s",
"myapp.mail.maxAttachmentSize=1MB",
"myapp.mail.smtpServers[0]=server1",
"myapp.mail.smtpServers[1]=server2",
"myapp.mail.maxAttachmentWeight=5kg"
"myapp.mail.enabled=asd",
"myapp.mail.defaultSubject=hello",
"myapp.mail.pauseBetweenMails=5s",
"myapp.mail.maxAttachmentSize=1MB",
"myapp.mail.smtpServers[0]=server1",
"myapp.mail.smtpServers[1]=server2",
"myapp.mail.maxAttachmentWeight=5kg"
})
class MailModuleTestWithAllProperties {
@Autowired(required = false)
private MailModuleProperties mailModuleProperties;
@Autowired(required = false)
private MailModuleProperties mailModuleProperties;
@Test
void propertiesAreLoaded() {
assertThat(mailModuleProperties).isNotNull();
assertThat(mailModuleProperties.getDefaultSubject()).isEqualTo("hello");
assertThat(mailModuleProperties.getEnabled()).isTrue();
assertThat(mailModuleProperties.getPauseBetweenMails()).isEqualByComparingTo(Duration.ofSeconds(5));
assertThat(mailModuleProperties.getMaxAttachmentSize()).isEqualByComparingTo(DataSize.ofMegabytes(1));
assertThat(mailModuleProperties.getSmtpServers()).hasSize(2);
assertThat(mailModuleProperties.getMaxAttachmentWeight().getGrams()).isEqualTo(5000L);
}
@Test
void propertiesAreLoaded() {
assertThat(mailModuleProperties).isNotNull();
assertThat(mailModuleProperties.getDefaultSubject()).isEqualTo("hello");
assertThat(mailModuleProperties.getEnabled()).isTrue();
assertThat(mailModuleProperties.getPauseBetweenMails()).isEqualByComparingTo(Duration.ofSeconds(5));
assertThat(mailModuleProperties.getMaxAttachmentSize()).isEqualByComparingTo(DataSize.ofMegabytes(1));
assertThat(mailModuleProperties.getSmtpServers()).hasSize(2);
assertThat(mailModuleProperties.getMaxAttachmentWeight().getGrams()).isEqualTo(5000L);
}
}

View File

@@ -70,8 +70,7 @@ class PropertiesInvalidInputTest {
assertThatThrownBy(application::run)
.isInstanceOf(ConfigurationPropertiesBindException.class)
.hasRootCauseInstanceOf(BindValidationException.class)
.hasStackTraceContaining("Field error in object 'app.properties' on field 'report.intervalInDays'")
.hasStackTraceContaining("[must be less than or equal to 30]");
.hasStackTraceContaining("rejected value [31]");
}
@@ -83,8 +82,7 @@ class PropertiesInvalidInputTest {
assertThatThrownBy(application::run)
.isInstanceOf(ConfigurationPropertiesBindException.class)
.hasRootCauseInstanceOf(BindValidationException.class)
.hasStackTraceContaining("Field error in object 'app.properties' on field 'report.intervalInDays'")
.hasStackTraceContaining("[must be greater than or equal to 7]");
.hasStackTraceContaining("rejected value [6]");
}
@@ -96,8 +94,7 @@ class PropertiesInvalidInputTest {
assertThatThrownBy(application::run)
.isInstanceOf(ConfigurationPropertiesBindException.class)
.hasRootCauseInstanceOf(BindValidationException.class)
.hasStackTraceContaining("Field error in object 'app.properties' on field 'report.emailAddress'")
.hasStackTraceContaining("[must be a well-formed email address]");
.hasStackTraceContaining("rejected value [manager.analysisapp.com]");
}