format all files
This commit is contained in:
@@ -21,98 +21,99 @@ import java.util.Properties;
|
|||||||
|
|
||||||
public class MavenWrapperDownloader {
|
public class MavenWrapperDownloader {
|
||||||
|
|
||||||
private static final String WRAPPER_VERSION = "0.5.6";
|
private static final String WRAPPER_VERSION = "0.5.6";
|
||||||
/**
|
/** Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. */
|
||||||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
private static final String DEFAULT_DOWNLOAD_URL =
|
||||||
*/
|
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
||||||
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
+ WRAPPER_VERSION
|
||||||
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
|
+ "/maven-wrapper-"
|
||||||
|
+ WRAPPER_VERSION
|
||||||
|
+ ".jar";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use
|
||||||
* use instead of the default one.
|
* instead of the default one.
|
||||||
*/
|
*/
|
||||||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||||
".mvn/wrapper/maven-wrapper.properties";
|
".mvn/wrapper/maven-wrapper.properties";
|
||||||
|
|
||||||
/**
|
/** Path where the maven-wrapper.jar will be saved to. */
|
||||||
* Path where the maven-wrapper.jar will be saved to.
|
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";
|
||||||
*/
|
|
||||||
private static final String MAVEN_WRAPPER_JAR_PATH =
|
|
||||||
".mvn/wrapper/maven-wrapper.jar";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the property which should be used to override the default download url for the wrapper.
|
* Name of the property which should be used to override the default download url for the wrapper.
|
||||||
*/
|
*/
|
||||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("- Downloader started");
|
System.out.println("- Downloader started");
|
||||||
File baseDirectory = new File(args[0]);
|
File baseDirectory = new File(args[0]);
|
||||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||||
|
|
||||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||||
// wrapperUrl parameter.
|
// wrapperUrl parameter.
|
||||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||||
String url = DEFAULT_DOWNLOAD_URL;
|
String url = DEFAULT_DOWNLOAD_URL;
|
||||||
if (mavenWrapperPropertyFile.exists()) {
|
if (mavenWrapperPropertyFile.exists()) {
|
||||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||||
try {
|
try {
|
||||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||||
Properties mavenWrapperProperties = new Properties();
|
Properties mavenWrapperProperties = new Properties();
|
||||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
if (mavenWrapperPropertyFileInputStream != null) {
|
|
||||||
mavenWrapperPropertyFileInputStream.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
// Ignore ...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("- Downloading from: " + url);
|
|
||||||
|
|
||||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
|
||||||
if (!outputFile.getParentFile().exists()) {
|
|
||||||
if (!outputFile.getParentFile().mkdirs()) {
|
|
||||||
System.out.println(
|
|
||||||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
|
||||||
try {
|
try {
|
||||||
downloadFileFromURL(url, outputFile);
|
if (mavenWrapperPropertyFileInputStream != null) {
|
||||||
System.out.println("Done");
|
mavenWrapperPropertyFileInputStream.close();
|
||||||
System.exit(0);
|
}
|
||||||
} catch (Throwable e) {
|
} catch (IOException e) {
|
||||||
System.out.println("- Error downloading");
|
// Ignore ...
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(1);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("- Downloading from: " + url);
|
||||||
|
|
||||||
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||||
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
if (!outputFile.getParentFile().exists()) {
|
||||||
String username = System.getenv("MVNW_USERNAME");
|
if (!outputFile.getParentFile().mkdirs()) {
|
||||||
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
System.out.println(
|
||||||
Authenticator.setDefault(new Authenticator() {
|
"- ERROR creating output directory '"
|
||||||
@Override
|
+ outputFile.getParentFile().getAbsolutePath()
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
+ "'");
|
||||||
return new PasswordAuthentication(username, password);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
URL website = new URL(urlString);
|
|
||||||
ReadableByteChannel rbc;
|
|
||||||
rbc = Channels.newChannel(website.openStream());
|
|
||||||
FileOutputStream fos = new FileOutputStream(destination);
|
|
||||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
|
||||||
fos.close();
|
|
||||||
rbc.close();
|
|
||||||
}
|
}
|
||||||
|
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||||
|
try {
|
||||||
|
downloadFileFromURL(url, outputFile);
|
||||||
|
System.out.println("Done");
|
||||||
|
System.exit(0);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
System.out.println("- Error downloading");
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||||
|
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
||||||
|
String username = System.getenv("MVNW_USERNAME");
|
||||||
|
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
||||||
|
Authenticator.setDefault(
|
||||||
|
new Authenticator() {
|
||||||
|
@Override
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(username, password);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
URL website = new URL(urlString);
|
||||||
|
ReadableByteChannel rbc;
|
||||||
|
rbc = Channels.newChannel(website.openStream());
|
||||||
|
FileOutputStream fos = new FileOutputStream(destination);
|
||||||
|
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||||
|
fos.close();
|
||||||
|
rbc.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
adapter/addressvalidation/mvnw
vendored
8
adapter/addressvalidation/mvnw
vendored
@@ -316,7 +316,7 @@ export MAVEN_CMD_LINE_ARGS
|
|||||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
exec "$JAVACMD" \
|
exec "$JAVACMD" \
|
||||||
$MAVEN_OPTS \
|
$MAVEN_OPTS \
|
||||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@@ -3,25 +3,25 @@ package de.strasser.peter.hexagonal.addressvalidation;
|
|||||||
import de.strasser.peter.hexagonal.application.customer.domain.Address;
|
import de.strasser.peter.hexagonal.application.customer.domain.Address;
|
||||||
import de.strasser.peter.hexagonal.application.customer.port.out.AddressValidatorPort;
|
import de.strasser.peter.hexagonal.application.customer.port.out.AddressValidatorPort;
|
||||||
import de.strasser.peter.hexagonal.application.customer.port.out.commands.ValidateAddressCommand;
|
import de.strasser.peter.hexagonal.application.customer.port.out.commands.ValidateAddressCommand;
|
||||||
|
import de.strasser.peter.hexagonal.common.Adapter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Adapter
|
||||||
class AddressValidator implements AddressValidatorPort {
|
class AddressValidator implements AddressValidatorPort {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Address validate(ValidateAddressCommand validateAddressCommand) throws InvalidAddressExc {
|
public Address validate(ValidateAddressCommand validateAddressCommand) throws InvalidAddressExc {
|
||||||
// This could be some call to a 3rd party to validate this address.
|
// This could be some call to a 3rd party to validate this address.
|
||||||
if (validateAddressCommand.getStreet().equalsIgnoreCase("parkring")) {
|
if (validateAddressCommand.getStreet().equalsIgnoreCase("parkring")) {
|
||||||
log.info("Address is made up.");
|
log.info("Address is made up.");
|
||||||
throw new InvalidAddressExc(validateAddressCommand);
|
throw new InvalidAddressExc(validateAddressCommand);
|
||||||
}
|
|
||||||
|
|
||||||
return new Address(
|
|
||||||
validateAddressCommand.getStreet(),
|
|
||||||
validateAddressCommand.getHouseNumber(),
|
|
||||||
validateAddressCommand.getZipCode(),
|
|
||||||
validateAddressCommand.getCountry());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new Address(
|
||||||
|
validateAddressCommand.getStreet(),
|
||||||
|
validateAddressCommand.getHouseNumber(),
|
||||||
|
validateAddressCommand.getZipCode(),
|
||||||
|
validateAddressCommand.getCountry());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,98 +21,99 @@ import java.util.Properties;
|
|||||||
|
|
||||||
public class MavenWrapperDownloader {
|
public class MavenWrapperDownloader {
|
||||||
|
|
||||||
private static final String WRAPPER_VERSION = "0.5.6";
|
private static final String WRAPPER_VERSION = "0.5.6";
|
||||||
/**
|
/** Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. */
|
||||||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
private static final String DEFAULT_DOWNLOAD_URL =
|
||||||
*/
|
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
||||||
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
+ WRAPPER_VERSION
|
||||||
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
|
+ "/maven-wrapper-"
|
||||||
|
+ WRAPPER_VERSION
|
||||||
|
+ ".jar";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use
|
||||||
* use instead of the default one.
|
* instead of the default one.
|
||||||
*/
|
*/
|
||||||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||||
".mvn/wrapper/maven-wrapper.properties";
|
".mvn/wrapper/maven-wrapper.properties";
|
||||||
|
|
||||||
/**
|
/** Path where the maven-wrapper.jar will be saved to. */
|
||||||
* Path where the maven-wrapper.jar will be saved to.
|
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";
|
||||||
*/
|
|
||||||
private static final String MAVEN_WRAPPER_JAR_PATH =
|
|
||||||
".mvn/wrapper/maven-wrapper.jar";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the property which should be used to override the default download url for the wrapper.
|
* Name of the property which should be used to override the default download url for the wrapper.
|
||||||
*/
|
*/
|
||||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("- Downloader started");
|
System.out.println("- Downloader started");
|
||||||
File baseDirectory = new File(args[0]);
|
File baseDirectory = new File(args[0]);
|
||||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||||
|
|
||||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||||
// wrapperUrl parameter.
|
// wrapperUrl parameter.
|
||||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||||
String url = DEFAULT_DOWNLOAD_URL;
|
String url = DEFAULT_DOWNLOAD_URL;
|
||||||
if (mavenWrapperPropertyFile.exists()) {
|
if (mavenWrapperPropertyFile.exists()) {
|
||||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||||
try {
|
try {
|
||||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||||
Properties mavenWrapperProperties = new Properties();
|
Properties mavenWrapperProperties = new Properties();
|
||||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
if (mavenWrapperPropertyFileInputStream != null) {
|
|
||||||
mavenWrapperPropertyFileInputStream.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
// Ignore ...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("- Downloading from: " + url);
|
|
||||||
|
|
||||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
|
||||||
if (!outputFile.getParentFile().exists()) {
|
|
||||||
if (!outputFile.getParentFile().mkdirs()) {
|
|
||||||
System.out.println(
|
|
||||||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
|
||||||
try {
|
try {
|
||||||
downloadFileFromURL(url, outputFile);
|
if (mavenWrapperPropertyFileInputStream != null) {
|
||||||
System.out.println("Done");
|
mavenWrapperPropertyFileInputStream.close();
|
||||||
System.exit(0);
|
}
|
||||||
} catch (Throwable e) {
|
} catch (IOException e) {
|
||||||
System.out.println("- Error downloading");
|
// Ignore ...
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(1);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("- Downloading from: " + url);
|
||||||
|
|
||||||
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||||
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
if (!outputFile.getParentFile().exists()) {
|
||||||
String username = System.getenv("MVNW_USERNAME");
|
if (!outputFile.getParentFile().mkdirs()) {
|
||||||
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
System.out.println(
|
||||||
Authenticator.setDefault(new Authenticator() {
|
"- ERROR creating output directory '"
|
||||||
@Override
|
+ outputFile.getParentFile().getAbsolutePath()
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
+ "'");
|
||||||
return new PasswordAuthentication(username, password);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
URL website = new URL(urlString);
|
|
||||||
ReadableByteChannel rbc;
|
|
||||||
rbc = Channels.newChannel(website.openStream());
|
|
||||||
FileOutputStream fos = new FileOutputStream(destination);
|
|
||||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
|
||||||
fos.close();
|
|
||||||
rbc.close();
|
|
||||||
}
|
}
|
||||||
|
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||||
|
try {
|
||||||
|
downloadFileFromURL(url, outputFile);
|
||||||
|
System.out.println("Done");
|
||||||
|
System.exit(0);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
System.out.println("- Error downloading");
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||||
|
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
||||||
|
String username = System.getenv("MVNW_USERNAME");
|
||||||
|
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
||||||
|
Authenticator.setDefault(
|
||||||
|
new Authenticator() {
|
||||||
|
@Override
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(username, password);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
URL website = new URL(urlString);
|
||||||
|
ReadableByteChannel rbc;
|
||||||
|
rbc = Channels.newChannel(website.openStream());
|
||||||
|
FileOutputStream fos = new FileOutputStream(destination);
|
||||||
|
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||||
|
fos.close();
|
||||||
|
rbc.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
adapter/persistence/mvnw
vendored
8
adapter/persistence/mvnw
vendored
@@ -316,7 +316,7 @@ export MAVEN_CMD_LINE_ARGS
|
|||||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
exec "$JAVACMD" \
|
exec "$JAVACMD" \
|
||||||
$MAVEN_OPTS \
|
$MAVEN_OPTS \
|
||||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Repository
|
@Repository
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CustomerDao
|
public class CustomerDao implements SaveCustomerPort, LoadCustomerPort, QueryAllCustomersCRUD {
|
||||||
implements SaveCustomerPort, LoadCustomerPort, QueryAllCustomersCRUD {
|
|
||||||
private final CustomerRepository customerRepository;
|
private final CustomerRepository customerRepository;
|
||||||
private final CustomerMapper customerMapper;
|
private final CustomerMapper customerMapper;
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@Configuration
|
@Configuration
|
||||||
public class MongoConfig {
|
public class MongoConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MongoClient mongoClient() {
|
public MongoClient mongoClient() {
|
||||||
return MongoClients.create("mongodb://admin:changeme@localhost:27017");
|
return MongoClients.create("mongodb://admin:changeme@localhost:27017");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,5 +7,4 @@ import org.springframework.stereotype.Repository;
|
|||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface CustomerRepository extends MongoRepository<CustomerEntity, BigInteger> {
|
public interface CustomerRepository extends MongoRepository<CustomerEntity, BigInteger> {}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package de.strasser.peter.hexagonal.persistence;
|
package de.strasser.peter.hexagonal.persistence;
|
||||||
|
|
||||||
import de.strasser.peter.hexagonal.application.customer.domain.Customer;
|
import de.strasser.peter.hexagonal.application.customer.domain.Customer;
|
||||||
import de.strasser.peter.hexagonal.persistence.mapper.CustomerMapper;
|
|
||||||
import de.strasser.peter.hexagonal.persistence.mapper.CustomerMapperImpl;
|
import de.strasser.peter.hexagonal.persistence.mapper.CustomerMapperImpl;
|
||||||
import de.strasser.peter.hexagonal.persistence.repository.CustomerRepository;
|
import de.strasser.peter.hexagonal.persistence.repository.CustomerRepository;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
@@ -18,24 +17,21 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
@DataMongoTest
|
@DataMongoTest
|
||||||
@Import({CustomerDao.class, CustomerMapperImpl.class})
|
@Import({CustomerDao.class, CustomerMapperImpl.class})
|
||||||
class CustomerDaoTest {
|
class CustomerDaoTest {
|
||||||
@Autowired
|
@Autowired private CustomerDao customerDao;
|
||||||
private CustomerDao customerDao;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired private CustomerRepository customerRepository;
|
||||||
private CustomerRepository customerRepository;
|
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void cleanUp() {
|
void cleanUp() {
|
||||||
this.customerRepository.deleteAll();
|
this.customerRepository.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Timeout(5)
|
@Timeout(5)
|
||||||
void should_ContainOneCustomer_When_CallingInsertMethod() {
|
void should_ContainOneCustomer_When_CallingInsertMethod() {
|
||||||
var customer = Customer.newCustomer("hans", "passwsord", LocalDate.of(1980, 1, 1));
|
var customer = Customer.newCustomer("hans", "passwsord", LocalDate.of(1980, 1, 1));
|
||||||
this.customerDao.upsert(customer);
|
this.customerDao.upsert(customer);
|
||||||
|
|
||||||
assertEquals(this.customerRepository.findAll().size(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
assertEquals(this.customerRepository.findAll().size(), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
package de.strasser.peter.hexagonal.persistence;
|
package de.strasser.peter.hexagonal.persistence;
|
||||||
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class PersistenceTestConfiguration {
|
public class PersistenceTestConfiguration {}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
167
adapter/web/.mvn/wrapper/MavenWrapperDownloader.java
vendored
167
adapter/web/.mvn/wrapper/MavenWrapperDownloader.java
vendored
@@ -21,98 +21,99 @@ import java.util.Properties;
|
|||||||
|
|
||||||
public class MavenWrapperDownloader {
|
public class MavenWrapperDownloader {
|
||||||
|
|
||||||
private static final String WRAPPER_VERSION = "0.5.6";
|
private static final String WRAPPER_VERSION = "0.5.6";
|
||||||
/**
|
/** Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. */
|
||||||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
private static final String DEFAULT_DOWNLOAD_URL =
|
||||||
*/
|
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
||||||
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
+ WRAPPER_VERSION
|
||||||
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
|
+ "/maven-wrapper-"
|
||||||
|
+ WRAPPER_VERSION
|
||||||
|
+ ".jar";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use
|
||||||
* use instead of the default one.
|
* instead of the default one.
|
||||||
*/
|
*/
|
||||||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||||
".mvn/wrapper/maven-wrapper.properties";
|
".mvn/wrapper/maven-wrapper.properties";
|
||||||
|
|
||||||
/**
|
/** Path where the maven-wrapper.jar will be saved to. */
|
||||||
* Path where the maven-wrapper.jar will be saved to.
|
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";
|
||||||
*/
|
|
||||||
private static final String MAVEN_WRAPPER_JAR_PATH =
|
|
||||||
".mvn/wrapper/maven-wrapper.jar";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the property which should be used to override the default download url for the wrapper.
|
* Name of the property which should be used to override the default download url for the wrapper.
|
||||||
*/
|
*/
|
||||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("- Downloader started");
|
System.out.println("- Downloader started");
|
||||||
File baseDirectory = new File(args[0]);
|
File baseDirectory = new File(args[0]);
|
||||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||||
|
|
||||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||||
// wrapperUrl parameter.
|
// wrapperUrl parameter.
|
||||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||||
String url = DEFAULT_DOWNLOAD_URL;
|
String url = DEFAULT_DOWNLOAD_URL;
|
||||||
if (mavenWrapperPropertyFile.exists()) {
|
if (mavenWrapperPropertyFile.exists()) {
|
||||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||||
try {
|
try {
|
||||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||||
Properties mavenWrapperProperties = new Properties();
|
Properties mavenWrapperProperties = new Properties();
|
||||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
if (mavenWrapperPropertyFileInputStream != null) {
|
|
||||||
mavenWrapperPropertyFileInputStream.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
// Ignore ...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("- Downloading from: " + url);
|
|
||||||
|
|
||||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
|
||||||
if (!outputFile.getParentFile().exists()) {
|
|
||||||
if (!outputFile.getParentFile().mkdirs()) {
|
|
||||||
System.out.println(
|
|
||||||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
|
||||||
try {
|
try {
|
||||||
downloadFileFromURL(url, outputFile);
|
if (mavenWrapperPropertyFileInputStream != null) {
|
||||||
System.out.println("Done");
|
mavenWrapperPropertyFileInputStream.close();
|
||||||
System.exit(0);
|
}
|
||||||
} catch (Throwable e) {
|
} catch (IOException e) {
|
||||||
System.out.println("- Error downloading");
|
// Ignore ...
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(1);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("- Downloading from: " + url);
|
||||||
|
|
||||||
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||||
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
if (!outputFile.getParentFile().exists()) {
|
||||||
String username = System.getenv("MVNW_USERNAME");
|
if (!outputFile.getParentFile().mkdirs()) {
|
||||||
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
System.out.println(
|
||||||
Authenticator.setDefault(new Authenticator() {
|
"- ERROR creating output directory '"
|
||||||
@Override
|
+ outputFile.getParentFile().getAbsolutePath()
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
+ "'");
|
||||||
return new PasswordAuthentication(username, password);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
URL website = new URL(urlString);
|
|
||||||
ReadableByteChannel rbc;
|
|
||||||
rbc = Channels.newChannel(website.openStream());
|
|
||||||
FileOutputStream fos = new FileOutputStream(destination);
|
|
||||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
|
||||||
fos.close();
|
|
||||||
rbc.close();
|
|
||||||
}
|
}
|
||||||
|
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||||
|
try {
|
||||||
|
downloadFileFromURL(url, outputFile);
|
||||||
|
System.out.println("Done");
|
||||||
|
System.exit(0);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
System.out.println("- Error downloading");
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||||
|
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
||||||
|
String username = System.getenv("MVNW_USERNAME");
|
||||||
|
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
||||||
|
Authenticator.setDefault(
|
||||||
|
new Authenticator() {
|
||||||
|
@Override
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(username, password);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
URL website = new URL(urlString);
|
||||||
|
ReadableByteChannel rbc;
|
||||||
|
rbc = Channels.newChannel(website.openStream());
|
||||||
|
FileOutputStream fos = new FileOutputStream(destination);
|
||||||
|
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||||
|
fos.close();
|
||||||
|
rbc.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
adapter/web/mvnw
vendored
8
adapter/web/mvnw
vendored
@@ -316,7 +316,7 @@ export MAVEN_CMD_LINE_ARGS
|
|||||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
exec "$JAVACMD" \
|
exec "$JAVACMD" \
|
||||||
$MAVEN_OPTS \
|
$MAVEN_OPTS \
|
||||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||||
|
|||||||
@@ -2,14 +2,19 @@ package de.strasser.peter.hexagonal.web;
|
|||||||
|
|
||||||
import de.strasser.peter.hexagonal.application.customer.port.in.AddAddressUseCase;
|
import de.strasser.peter.hexagonal.application.customer.port.in.AddAddressUseCase;
|
||||||
import de.strasser.peter.hexagonal.application.customer.port.in.commands.AddAddressCommand;
|
import de.strasser.peter.hexagonal.application.customer.port.in.commands.AddAddressCommand;
|
||||||
|
import de.strasser.peter.hexagonal.common.Adapter;
|
||||||
import de.strasser.peter.hexagonal.web.dto.request.AddAddressRequest;
|
import de.strasser.peter.hexagonal.web.dto.request.AddAddressRequest;
|
||||||
import de.strasser.peter.hexagonal.web.mapper.AddAddressWebMapper;
|
import de.strasser.peter.hexagonal.web.mapper.AddAddressWebMapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Adapter
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class AddAddressController {
|
public class AddAddressController {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package de.strasser.peter.hexagonal.web;
|
package de.strasser.peter.hexagonal.web;
|
||||||
|
|
||||||
import de.strasser.peter.hexagonal.application.customer.port.in.QueryAllCustomersCRUD;
|
import de.strasser.peter.hexagonal.application.customer.port.in.QueryAllCustomersCRUD;
|
||||||
|
import de.strasser.peter.hexagonal.common.Adapter;
|
||||||
import de.strasser.peter.hexagonal.web.dto.response.CustomerResponse;
|
import de.strasser.peter.hexagonal.web.dto.response.CustomerResponse;
|
||||||
import de.strasser.peter.hexagonal.web.mapper.CustomerWebMapper;
|
import de.strasser.peter.hexagonal.web.mapper.CustomerWebMapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -9,6 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Adapter
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CustomerCRUDController {
|
public class CustomerCRUDController {
|
||||||
|
|||||||
@@ -1,21 +1,23 @@
|
|||||||
package de.strasser.peter.hexagonal.web;
|
package de.strasser.peter.hexagonal.web;
|
||||||
|
|
||||||
import de.strasser.peter.hexagonal.application.customer.port.in.RegisterCustomerUseCase;
|
import de.strasser.peter.hexagonal.application.customer.port.in.RegisterCustomerUseCase;
|
||||||
import de.strasser.peter.hexagonal.web.mapper.RegisterCustomerWebMapper;
|
import de.strasser.peter.hexagonal.common.Adapter;
|
||||||
import de.strasser.peter.hexagonal.web.dto.request.RegisterCustomerRequest;
|
import de.strasser.peter.hexagonal.web.dto.request.RegisterCustomerRequest;
|
||||||
|
import de.strasser.peter.hexagonal.web.mapper.RegisterCustomerWebMapper;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Adapter
|
||||||
@RestController
|
@RestController
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class RegisterCustomerController {
|
public class RegisterCustomerController {
|
||||||
private final RegisterCustomerUseCase registerCustomerUseCase;
|
private final RegisterCustomerUseCase registerCustomerUseCase;
|
||||||
private final RegisterCustomerWebMapper registerCustomerMapper;
|
private final RegisterCustomerWebMapper registerCustomerMapper;
|
||||||
|
|
||||||
@PostMapping("/v1/register")
|
@PostMapping("/v1/register")
|
||||||
public void registerCustomer(@RequestBody RegisterCustomerRequest registerCustomerRequest) {
|
public void registerCustomer(@RequestBody RegisterCustomerRequest registerCustomerRequest) {
|
||||||
registerCustomerUseCase.register(registerCustomerMapper.toCmd(registerCustomerRequest));
|
registerCustomerUseCase.register(registerCustomerMapper.toCmd(registerCustomerRequest));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,4 @@ package de.strasser.peter.hexagonal.web.config;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class WebConfig {
|
public class WebConfig {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor(force = true)
|
@NoArgsConstructor(force = true)
|
||||||
public class AddAddressRequest {
|
public class AddAddressRequest {
|
||||||
String type;
|
String type;
|
||||||
String street;
|
String street;
|
||||||
Integer houseNumber;
|
Integer houseNumber;
|
||||||
Integer zipCode;
|
Integer zipCode;
|
||||||
String country;
|
String country;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.time.LocalDate;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor(force = true)
|
@NoArgsConstructor(force = true)
|
||||||
public class RegisterCustomerRequest {
|
public class RegisterCustomerRequest {
|
||||||
String name;
|
String name;
|
||||||
LocalDate birthDay;
|
LocalDate birthDay;
|
||||||
String password;
|
String password;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package de.strasser.peter.hexagonal.web.dto.response;
|
|||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
public enum AddressTypeResponse {
|
public enum AddressTypeResponse {
|
||||||
@JsonProperty("default")
|
@JsonProperty("default")
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
@JsonProperty("shipping")
|
@JsonProperty("shipping")
|
||||||
SHIPPING,
|
SHIPPING,
|
||||||
@JsonProperty("billing")
|
@JsonProperty("billing")
|
||||||
BILLING;
|
BILLING;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package de.strasser.peter.hexagonal.web.dto.response;
|
package de.strasser.peter.hexagonal.web.dto.response;
|
||||||
|
|
||||||
import de.strasser.peter.hexagonal.application.customer.domain.Address;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|||||||
@@ -14,32 +14,36 @@ import java.time.LocalDateTime;
|
|||||||
@ControllerAdvice
|
@ControllerAdvice
|
||||||
public class ErrorHandling {
|
public class ErrorHandling {
|
||||||
|
|
||||||
@ExceptionHandler(ConstraintViolationException.class)
|
@ExceptionHandler(ConstraintViolationException.class)
|
||||||
public ResponseEntity<ErrorResponse> constrainViolationException(HttpServletRequest req, ConstraintViolationException exc) {
|
public ResponseEntity<ErrorResponse> constrainViolationException(
|
||||||
return ErrorResponse.createErrorResp(req, HttpStatus.BAD_REQUEST, exc);
|
HttpServletRequest req, ConstraintViolationException exc) {
|
||||||
}
|
return ErrorResponse.createErrorResp(req, HttpStatus.BAD_REQUEST, exc);
|
||||||
|
}
|
||||||
|
|
||||||
@ExceptionHandler(BusinessException.class)
|
@ExceptionHandler(BusinessException.class)
|
||||||
public ResponseEntity<ErrorResponse> constrainViolationException(HttpServletRequest req, BusinessException exc) {
|
public ResponseEntity<ErrorResponse> constrainViolationException(
|
||||||
return ErrorResponse.createErrorResp(req, HttpStatus.BAD_REQUEST, exc);
|
HttpServletRequest req, BusinessException exc) {
|
||||||
}
|
return ErrorResponse.createErrorResp(req, HttpStatus.BAD_REQUEST, exc);
|
||||||
|
}
|
||||||
|
|
||||||
@Value
|
@Value
|
||||||
public static class ErrorResponse {
|
public static class ErrorResponse {
|
||||||
String timestamp;
|
String timestamp;
|
||||||
Integer status;
|
Integer status;
|
||||||
String error;
|
String error;
|
||||||
String message;
|
String message;
|
||||||
String path;
|
String path;
|
||||||
|
|
||||||
public static ResponseEntity<ErrorResponse> createErrorResp(HttpServletRequest req, HttpStatus code, Exception e) {
|
public static ResponseEntity<ErrorResponse> createErrorResp(
|
||||||
final ErrorResponse errResponse = new ErrorResponse(
|
HttpServletRequest req, HttpStatus code, Exception e) {
|
||||||
LocalDateTime.now().toString(),
|
final ErrorResponse errResponse =
|
||||||
code.value(),
|
new ErrorResponse(
|
||||||
e.getClass().getSimpleName(),
|
LocalDateTime.now().toString(),
|
||||||
e.getMessage(),
|
code.value(),
|
||||||
req.getRequestURI());
|
e.getClass().getSimpleName(),
|
||||||
return ResponseEntity.status(code).body(errResponse);
|
e.getMessage(),
|
||||||
}
|
req.getRequestURI());
|
||||||
|
return ResponseEntity.status(code).body(errResponse);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ import org.mapstruct.Mapper;
|
|||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface AddAddressWebMapper {
|
public interface AddAddressWebMapper {
|
||||||
AddAddressCommand toCmd(AddAddressRequest addAddressRequest);
|
AddAddressCommand toCmd(AddAddressRequest addAddressRequest);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,5 +11,4 @@ public interface CustomerWebMapper {
|
|||||||
CustomerResponse toResponse(Customer customer);
|
CustomerResponse toResponse(Customer customer);
|
||||||
|
|
||||||
List<CustomerResponse> toResponse(List<Customer> customer);
|
List<CustomerResponse> toResponse(List<Customer> customer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ import org.mapstruct.Mapping;
|
|||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface RegisterCustomerWebMapper {
|
public interface RegisterCustomerWebMapper {
|
||||||
@Mapping(source = "password", target = "clearPassword")
|
@Mapping(source = "password", target = "clearPassword")
|
||||||
RegisterCustomerCommand toCmd(RegisterCustomerRequest registerCustomerRequest);
|
RegisterCustomerCommand toCmd(RegisterCustomerRequest registerCustomerRequest);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ class RegisterCustomerControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void should_DenyRequest_When_SendingInvalidDateFormat() throws Exception {
|
public void should_DenyRequest_When_SendingInvalidDateFormat() throws Exception {
|
||||||
final String body = ReadStringResources.readStringFromResource("invalid_date_register_customer.json");
|
final String body =
|
||||||
|
ReadStringResources.readStringFromResource("invalid_date_register_customer.json");
|
||||||
|
|
||||||
mockMvc
|
mockMvc
|
||||||
.perform(post("/v1/register").contentType(MediaType.APPLICATION_JSON).content(body))
|
.perform(post("/v1/register").contentType(MediaType.APPLICATION_JSON).content(body))
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
package de.strasser.peter.hexagonal.web;
|
package de.strasser.peter.hexagonal.web;
|
||||||
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class WebTestConfiguration {
|
public class WebTestConfiguration {}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
167
application/.mvn/wrapper/MavenWrapperDownloader.java
vendored
167
application/.mvn/wrapper/MavenWrapperDownloader.java
vendored
@@ -21,98 +21,99 @@ import java.util.Properties;
|
|||||||
|
|
||||||
public class MavenWrapperDownloader {
|
public class MavenWrapperDownloader {
|
||||||
|
|
||||||
private static final String WRAPPER_VERSION = "0.5.6";
|
private static final String WRAPPER_VERSION = "0.5.6";
|
||||||
/**
|
/** Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. */
|
||||||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
private static final String DEFAULT_DOWNLOAD_URL =
|
||||||
*/
|
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
||||||
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
+ WRAPPER_VERSION
|
||||||
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
|
+ "/maven-wrapper-"
|
||||||
|
+ WRAPPER_VERSION
|
||||||
|
+ ".jar";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use
|
||||||
* use instead of the default one.
|
* instead of the default one.
|
||||||
*/
|
*/
|
||||||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||||
".mvn/wrapper/maven-wrapper.properties";
|
".mvn/wrapper/maven-wrapper.properties";
|
||||||
|
|
||||||
/**
|
/** Path where the maven-wrapper.jar will be saved to. */
|
||||||
* Path where the maven-wrapper.jar will be saved to.
|
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";
|
||||||
*/
|
|
||||||
private static final String MAVEN_WRAPPER_JAR_PATH =
|
|
||||||
".mvn/wrapper/maven-wrapper.jar";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the property which should be used to override the default download url for the wrapper.
|
* Name of the property which should be used to override the default download url for the wrapper.
|
||||||
*/
|
*/
|
||||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("- Downloader started");
|
System.out.println("- Downloader started");
|
||||||
File baseDirectory = new File(args[0]);
|
File baseDirectory = new File(args[0]);
|
||||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||||
|
|
||||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||||
// wrapperUrl parameter.
|
// wrapperUrl parameter.
|
||||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||||
String url = DEFAULT_DOWNLOAD_URL;
|
String url = DEFAULT_DOWNLOAD_URL;
|
||||||
if (mavenWrapperPropertyFile.exists()) {
|
if (mavenWrapperPropertyFile.exists()) {
|
||||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||||
try {
|
try {
|
||||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||||
Properties mavenWrapperProperties = new Properties();
|
Properties mavenWrapperProperties = new Properties();
|
||||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
if (mavenWrapperPropertyFileInputStream != null) {
|
|
||||||
mavenWrapperPropertyFileInputStream.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
// Ignore ...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("- Downloading from: " + url);
|
|
||||||
|
|
||||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
|
||||||
if (!outputFile.getParentFile().exists()) {
|
|
||||||
if (!outputFile.getParentFile().mkdirs()) {
|
|
||||||
System.out.println(
|
|
||||||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
|
||||||
try {
|
try {
|
||||||
downloadFileFromURL(url, outputFile);
|
if (mavenWrapperPropertyFileInputStream != null) {
|
||||||
System.out.println("Done");
|
mavenWrapperPropertyFileInputStream.close();
|
||||||
System.exit(0);
|
}
|
||||||
} catch (Throwable e) {
|
} catch (IOException e) {
|
||||||
System.out.println("- Error downloading");
|
// Ignore ...
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(1);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("- Downloading from: " + url);
|
||||||
|
|
||||||
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||||
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
if (!outputFile.getParentFile().exists()) {
|
||||||
String username = System.getenv("MVNW_USERNAME");
|
if (!outputFile.getParentFile().mkdirs()) {
|
||||||
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
System.out.println(
|
||||||
Authenticator.setDefault(new Authenticator() {
|
"- ERROR creating output directory '"
|
||||||
@Override
|
+ outputFile.getParentFile().getAbsolutePath()
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
+ "'");
|
||||||
return new PasswordAuthentication(username, password);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
URL website = new URL(urlString);
|
|
||||||
ReadableByteChannel rbc;
|
|
||||||
rbc = Channels.newChannel(website.openStream());
|
|
||||||
FileOutputStream fos = new FileOutputStream(destination);
|
|
||||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
|
||||||
fos.close();
|
|
||||||
rbc.close();
|
|
||||||
}
|
}
|
||||||
|
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||||
|
try {
|
||||||
|
downloadFileFromURL(url, outputFile);
|
||||||
|
System.out.println("Done");
|
||||||
|
System.exit(0);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
System.out.println("- Error downloading");
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||||
|
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
||||||
|
String username = System.getenv("MVNW_USERNAME");
|
||||||
|
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
||||||
|
Authenticator.setDefault(
|
||||||
|
new Authenticator() {
|
||||||
|
@Override
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(username, password);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
URL website = new URL(urlString);
|
||||||
|
ReadableByteChannel rbc;
|
||||||
|
rbc = Channels.newChannel(website.openStream());
|
||||||
|
FileOutputStream fos = new FileOutputStream(destination);
|
||||||
|
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||||
|
fos.close();
|
||||||
|
rbc.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
application/mvnw
vendored
8
application/mvnw
vendored
@@ -316,7 +316,7 @@ export MAVEN_CMD_LINE_ARGS
|
|||||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
exec "$JAVACMD" \
|
exec "$JAVACMD" \
|
||||||
$MAVEN_OPTS \
|
$MAVEN_OPTS \
|
||||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package de.strasser.peter.hexagonal.application.customer.exception;
|
package de.strasser.peter.hexagonal.application.customer.exception;
|
||||||
|
|
||||||
public class AddressTypeDoesNotExistsExc extends BusinessException {
|
public class AddressTypeDoesNotExistsExc extends BusinessException {
|
||||||
public AddressTypeDoesNotExistsExc(String type) {
|
public AddressTypeDoesNotExistsExc(String type) {
|
||||||
super(String.format("Adress of type '%s' does not exist!", type));
|
super(String.format("Adress of type '%s' does not exist!", type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package de.strasser.peter.hexagonal.application.customer.exception;
|
package de.strasser.peter.hexagonal.application.customer.exception;
|
||||||
|
|
||||||
public abstract class BusinessException extends IllegalStateException {
|
public abstract class BusinessException extends IllegalStateException {
|
||||||
public BusinessException(String error) {
|
public BusinessException(String error) {
|
||||||
super(error);
|
super(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package de.strasser.peter.hexagonal.application.customer.exception;
|
|||||||
|
|
||||||
public class DefaultAdressRequiredToActivateExc extends BusinessException {
|
public class DefaultAdressRequiredToActivateExc extends BusinessException {
|
||||||
|
|
||||||
public DefaultAdressRequiredToActivateExc() {
|
public DefaultAdressRequiredToActivateExc() {
|
||||||
super("Customer needs to have at least a default adress to be able to be activated!");
|
super("Customer needs to have at least a default adress to be able to be activated!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package de.strasser.peter.hexagonal.application.customer.exception;
|
|||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
public class TooYoungExc extends BusinessException {
|
public class TooYoungExc extends BusinessException {
|
||||||
public TooYoungExc(int age) {
|
public TooYoungExc(int age) {
|
||||||
super(MessageFormat.format("Customer is too young. Expected: > 18 yrs, Actual: {0}", age));
|
super(MessageFormat.format("Customer is too young. Expected: > 18 yrs, Actual: {0}", age));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ import org.mapstruct.Mapper;
|
|||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface AddAddressMapper {
|
public interface AddAddressMapper {
|
||||||
ValidateAddressCommand toOutCmd(AddAddressCommand addAddressCommand);
|
ValidateAddressCommand toOutCmd(AddAddressCommand addAddressCommand);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,6 @@ import java.math.BigInteger;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface AddAddressUseCase {
|
public interface AddAddressUseCase {
|
||||||
void addAddresses(@Min(0) BigInteger customerId, @Valid @NotEmpty List<AddAddressCommand> addresses);
|
void addAddresses(
|
||||||
|
@Min(0) BigInteger customerId, @Valid @NotEmpty List<AddAddressCommand> addresses);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ import de.strasser.peter.hexagonal.application.customer.port.in.commands.Registe
|
|||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
public interface RegisterCustomerUseCase {
|
public interface RegisterCustomerUseCase {
|
||||||
void register(@Valid RegisterCustomerCommand registerCustomerCommand);
|
void register(@Valid RegisterCustomerCommand registerCustomerCommand);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ import javax.validation.constraints.NotEmpty;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor(force = true)
|
@NoArgsConstructor(force = true)
|
||||||
public class AddAddressCommand {
|
public class AddAddressCommand {
|
||||||
@NotEmpty String type;
|
@NotEmpty String type;
|
||||||
@NotEmpty String street;
|
@NotEmpty String street;
|
||||||
Integer houseNumber;
|
Integer houseNumber;
|
||||||
@Min(0)
|
|
||||||
Integer zipCode;
|
@Min(0)
|
||||||
@NotEmpty String country;
|
Integer zipCode;
|
||||||
|
|
||||||
|
@NotEmpty String country;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package de.strasser.peter.hexagonal.application.customer.port.in.commands;
|
package de.strasser.peter.hexagonal.application.customer.port.in.commands;
|
||||||
|
|
||||||
|
|
||||||
import de.strasser.peter.hexagonal.application.customer.validator.SecurePassword;
|
import de.strasser.peter.hexagonal.application.customer.validator.SecurePassword;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -14,7 +13,7 @@ import java.time.LocalDate;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor(force = true)
|
@NoArgsConstructor(force = true)
|
||||||
public class RegisterCustomerCommand {
|
public class RegisterCustomerCommand {
|
||||||
@NotEmpty String name;
|
@NotEmpty String name;
|
||||||
@Past LocalDate birthDay;
|
@Past LocalDate birthDay;
|
||||||
@SecurePassword String clearPassword;
|
@SecurePassword String clearPassword;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ import de.strasser.peter.hexagonal.application.customer.domain.Address;
|
|||||||
import de.strasser.peter.hexagonal.application.customer.port.out.commands.ValidateAddressCommand;
|
import de.strasser.peter.hexagonal.application.customer.port.out.commands.ValidateAddressCommand;
|
||||||
|
|
||||||
public interface AddressValidatorPort {
|
public interface AddressValidatorPort {
|
||||||
Address validate(ValidateAddressCommand validateAddressCommand);
|
Address validate(ValidateAddressCommand validateAddressCommand);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ import de.strasser.peter.hexagonal.application.customer.domain.Customer;
|
|||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
public interface LoadCustomerPort {
|
public interface LoadCustomerPort {
|
||||||
Customer findById(BigInteger id);
|
Customer findById(BigInteger id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ package de.strasser.peter.hexagonal.application.customer.port.out;
|
|||||||
import de.strasser.peter.hexagonal.application.customer.domain.Customer;
|
import de.strasser.peter.hexagonal.application.customer.domain.Customer;
|
||||||
|
|
||||||
public interface SaveCustomerPort {
|
public interface SaveCustomerPort {
|
||||||
void upsert(Customer customer);
|
void upsert(Customer customer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,28 +22,30 @@ import java.util.Map;
|
|||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
class AddressService implements AddAddressUseCase {
|
class AddressService implements AddAddressUseCase {
|
||||||
private final SaveCustomerPort saveCustomerAdapter;
|
private final SaveCustomerPort saveCustomerAdapter;
|
||||||
private final AddressValidatorPort addressValidatorAdapter;
|
private final AddressValidatorPort addressValidatorAdapter;
|
||||||
private final LoadCustomerPort loadCustomerAdapter;
|
private final LoadCustomerPort loadCustomerAdapter;
|
||||||
private final AddAddressMapper addAddressMapper;
|
private final AddAddressMapper addAddressMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addAddresses(@Min(0) BigInteger customerId, @Valid @NotEmpty List<AddAddressCommand> addAddressCmds) {
|
public void addAddresses(
|
||||||
final Customer customer = loadCustomerAdapter.findById(customerId);
|
@Min(0) BigInteger customerId, @Valid @NotEmpty List<AddAddressCommand> addAddressCmds) {
|
||||||
|
final Customer customer = loadCustomerAdapter.findById(customerId);
|
||||||
|
|
||||||
final Map<Address.AddressType, Address> addresses = new HashMap<>();
|
final Map<Address.AddressType, Address> addresses = new HashMap<>();
|
||||||
addAddressCmds.forEach(addAddressCommand -> validateAndAddToMap(addresses, addAddressCommand));
|
addAddressCmds.forEach(addAddressCommand -> validateAndAddToMap(addresses, addAddressCommand));
|
||||||
|
|
||||||
customer.addAddresses(addresses);
|
customer.addAddresses(addresses);
|
||||||
|
|
||||||
saveCustomerAdapter.upsert(customer);
|
saveCustomerAdapter.upsert(customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateAndAddToMap(Map<Address.AddressType, Address> addresses, AddAddressCommand addAddressCommand) {
|
private void validateAndAddToMap(
|
||||||
final var addressType = Address.AddressType.fromString(addAddressCommand.getType());
|
Map<Address.AddressType, Address> addresses, AddAddressCommand addAddressCommand) {
|
||||||
final var validateAddressCmd = addAddressMapper.toOutCmd(addAddressCommand);
|
final var addressType = Address.AddressType.fromString(addAddressCommand.getType());
|
||||||
final var validatedAddress = addressValidatorAdapter.validate(validateAddressCmd);
|
final var validateAddressCmd = addAddressMapper.toOutCmd(addAddressCommand);
|
||||||
|
final var validatedAddress = addressValidatorAdapter.validate(validateAddressCmd);
|
||||||
|
|
||||||
addresses.put(addressType, validatedAddress);
|
addresses.put(addressType, validatedAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,17 +16,18 @@ import javax.validation.Valid;
|
|||||||
@Validated
|
@Validated
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
class RegisterCustomerService implements RegisterCustomerUseCase {
|
class RegisterCustomerService implements RegisterCustomerUseCase {
|
||||||
private final SaveCustomerPort saveUser;
|
private final SaveCustomerPort saveUser;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(@Valid RegisterCustomerCommand registerCmd) {
|
public void register(@Valid RegisterCustomerCommand registerCmd) {
|
||||||
var encryptedPw = this.superSecureHashingAlgorithm(registerCmd.getClearPassword());
|
var encryptedPw = this.superSecureHashingAlgorithm(registerCmd.getClearPassword());
|
||||||
var newCustomer = Customer.newCustomer(registerCmd.getName(), encryptedPw, registerCmd.getBirthDay());
|
var newCustomer =
|
||||||
|
Customer.newCustomer(registerCmd.getName(), encryptedPw, registerCmd.getBirthDay());
|
||||||
|
|
||||||
saveUser.upsert(newCustomer);
|
saveUser.upsert(newCustomer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String superSecureHashingAlgorithm(String s) {
|
private String superSecureHashingAlgorithm(String s) {
|
||||||
return new StringBuilder(s).reverse().toString();
|
return new StringBuilder(s).reverse().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ package de.strasser.peter.hexagonal.application.customer.domain;
|
|||||||
|
|
||||||
import de.strasser.peter.hexagonal.application.customer.exception.TooOldToDeactivateExc;
|
import de.strasser.peter.hexagonal.application.customer.exception.TooOldToDeactivateExc;
|
||||||
import de.strasser.peter.hexagonal.application.customer.exception.TooYoungExc;
|
import de.strasser.peter.hexagonal.application.customer.exception.TooYoungExc;
|
||||||
import de.strasser.peter.hexagonal.application.customer.mapper.AddAddressMapper;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -13,7 +11,6 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
|
|
||||||
class CustomerTest {
|
class CustomerTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void should_CreateNewCustomer() {
|
public void should_CreateNewCustomer() {
|
||||||
final var customer = Customer.newCustomer("name", "pw", LocalDate.of(1980, 1, 1));
|
final var customer = Customer.newCustomer("name", "pw", LocalDate.of(1980, 1, 1));
|
||||||
@@ -57,10 +54,8 @@ class CustomerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void should_ThrowTooOldErr_When_DeactivatingOldCustomer(){
|
public void should_ThrowTooOldErr_When_DeactivatingOldCustomer() {
|
||||||
final Customer customer = Customer.newCustomer("name", "pw", LocalDate.of(1950, 1, 1));
|
final Customer customer = Customer.newCustomer("name", "pw", LocalDate.of(1950, 1, 1));
|
||||||
assertThrows(TooOldToDeactivateExc.class, customer::deactivate);
|
assertThrows(TooOldToDeactivateExc.class, customer::deactivate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package de.strasser.peter.hexagonal.application.customer.service;
|
|||||||
|
|
||||||
import de.strasser.peter.hexagonal.application.customer.domain.Address;
|
import de.strasser.peter.hexagonal.application.customer.domain.Address;
|
||||||
import de.strasser.peter.hexagonal.application.customer.domain.Customer;
|
import de.strasser.peter.hexagonal.application.customer.domain.Customer;
|
||||||
import de.strasser.peter.hexagonal.application.customer.mapper.AddAddressMapper;
|
|
||||||
import de.strasser.peter.hexagonal.application.customer.port.in.commands.AddAddressCommand;
|
import de.strasser.peter.hexagonal.application.customer.port.in.commands.AddAddressCommand;
|
||||||
import de.strasser.peter.hexagonal.application.customer.port.out.AddressValidatorPort;
|
import de.strasser.peter.hexagonal.application.customer.port.out.AddressValidatorPort;
|
||||||
import de.strasser.peter.hexagonal.application.customer.port.out.LoadCustomerPort;
|
import de.strasser.peter.hexagonal.application.customer.port.out.LoadCustomerPort;
|
||||||
@@ -12,7 +11,6 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package de.strasser.peter.hexagonal.application.customer.service;
|
package de.strasser.peter.hexagonal.application.customer.service;
|
||||||
|
|
||||||
import de.strasser.peter.hexagonal.application.customer.mapper.AddAddressMapper;
|
|
||||||
import de.strasser.peter.hexagonal.application.customer.port.in.commands.RegisterCustomerCommand;
|
import de.strasser.peter.hexagonal.application.customer.port.in.commands.RegisterCustomerCommand;
|
||||||
import de.strasser.peter.hexagonal.application.customer.port.out.AddressValidatorPort;
|
import de.strasser.peter.hexagonal.application.customer.port.out.AddressValidatorPort;
|
||||||
import de.strasser.peter.hexagonal.application.customer.port.out.LoadCustomerPort;
|
import de.strasser.peter.hexagonal.application.customer.port.out.LoadCustomerPort;
|
||||||
@@ -21,48 +20,47 @@ import static org.mockito.BDDMockito.willDoNothing;
|
|||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class RegisterCustomerServiceTest {
|
class RegisterCustomerServiceTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired private RegisterCustomerService sut;
|
||||||
private RegisterCustomerService sut;
|
|
||||||
|
|
||||||
@MockBean
|
@MockBean private SaveCustomerPort saveCustomerAdapterMock;
|
||||||
private SaveCustomerPort saveCustomerAdapterMock;
|
@MockBean private AddressValidatorPort addressValidatorAdapterMock;
|
||||||
@MockBean
|
@MockBean private LoadCustomerPort loadCustomerAdapterMock;
|
||||||
private AddressValidatorPort addressValidatorAdapterMock;
|
|
||||||
@MockBean
|
|
||||||
private LoadCustomerPort loadCustomerAdapterMock;
|
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void setUp() {
|
||||||
|
willDoNothing().given(saveCustomerAdapterMock).upsert(any());
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@Test
|
||||||
public void setUp() {
|
public void should_ThrowInvalidBirthDate_When_PassingDateInFuture() {
|
||||||
willDoNothing().given(saveCustomerAdapterMock).upsert(any());
|
RegisterCustomerCommand registerCustomerCommand =
|
||||||
}
|
new RegisterCustomerCommand("Hans", LocalDate.now().plusDays(1), "secretPassword");
|
||||||
|
|
||||||
@Test
|
assertThrows(
|
||||||
public void should_ThrowInvalidBirthDate_When_PassingDateInFuture() {
|
ConstraintViolationException.class,
|
||||||
RegisterCustomerCommand registerCustomerCommand =
|
() -> {
|
||||||
new RegisterCustomerCommand("Hans", LocalDate.now().plusDays(1), "secretPassword");
|
sut.register(registerCustomerCommand);
|
||||||
|
|
||||||
assertThrows(ConstraintViolationException.class, () -> {
|
|
||||||
sut.register(registerCustomerCommand);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void should_ThrowInvalidPassword_When_PassingInsecurePassword() {
|
public void should_ThrowInvalidPassword_When_PassingInsecurePassword() {
|
||||||
LocalDate birthday = LocalDate.of(1980, 1, 1);
|
LocalDate birthday = LocalDate.of(1980, 1, 1);
|
||||||
RegisterCustomerCommand registerCustomerCommand =
|
RegisterCustomerCommand registerCustomerCommand =
|
||||||
new RegisterCustomerCommand("Hans", birthday, "secretPassword");
|
new RegisterCustomerCommand("Hans", birthday, "secretPassword");
|
||||||
|
|
||||||
assertThrows(ConstraintViolationException.class, () -> {
|
assertThrows(
|
||||||
sut.register(registerCustomerCommand);
|
ConstraintViolationException.class,
|
||||||
|
() -> {
|
||||||
|
sut.register(registerCustomerCommand);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void should_SaveUser() {
|
public void should_SaveUser() {
|
||||||
LocalDate birthday = LocalDate.of(1980, 1, 1);
|
LocalDate birthday = LocalDate.of(1980, 1, 1);
|
||||||
RegisterCustomerCommand registerCustomerCommand =
|
RegisterCustomerCommand registerCustomerCommand =
|
||||||
new RegisterCustomerCommand("Hans", birthday, "Ha012!321+dw");
|
new RegisterCustomerCommand("Hans", birthday, "Ha012!321+dw");
|
||||||
sut.register(registerCustomerCommand);
|
sut.register(registerCustomerCommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package de.strasser.peter.hexagonal.common;
|
||||||
|
|
||||||
|
import org.springframework.core.annotation.AliasFor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target({ElementType.TYPE})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Component
|
||||||
|
public @interface Adapter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value may indicate a suggestion for a logical component name, to be turned into a Spring
|
||||||
|
* bean in case of an autodetected component.
|
||||||
|
*
|
||||||
|
* @return the suggested component name, if any (or empty String otherwise)
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = Component.class)
|
||||||
|
String value() default "";
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package de.strasser.peter.hexagonal.common.validators;
|
package de.strasser.peter.hexagonal.common;
|
||||||
|
|
||||||
import org.springframework.util.ResourceUtils;
|
import org.springframework.util.ResourceUtils;
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package de.strasser.peter.hexagonal.common;
|
||||||
|
|
||||||
|
import org.springframework.core.annotation.AliasFor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target({ElementType.TYPE})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Component
|
||||||
|
public @interface UseCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value may indicate a suggestion for a logical component name, to be turned into a Spring
|
||||||
|
* bean in case of an autodetected component.
|
||||||
|
*
|
||||||
|
* @return the suggested component name, if any (or empty String otherwise)
|
||||||
|
*/
|
||||||
|
@AliasFor(annotation = Component.class)
|
||||||
|
String value() default "";
|
||||||
|
}
|
||||||
167
config/.mvn/wrapper/MavenWrapperDownloader.java
vendored
167
config/.mvn/wrapper/MavenWrapperDownloader.java
vendored
@@ -21,98 +21,99 @@ import java.util.Properties;
|
|||||||
|
|
||||||
public class MavenWrapperDownloader {
|
public class MavenWrapperDownloader {
|
||||||
|
|
||||||
private static final String WRAPPER_VERSION = "0.5.6";
|
private static final String WRAPPER_VERSION = "0.5.6";
|
||||||
/**
|
/** Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. */
|
||||||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
private static final String DEFAULT_DOWNLOAD_URL =
|
||||||
*/
|
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
||||||
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
+ WRAPPER_VERSION
|
||||||
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
|
+ "/maven-wrapper-"
|
||||||
|
+ WRAPPER_VERSION
|
||||||
|
+ ".jar";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use
|
||||||
* use instead of the default one.
|
* instead of the default one.
|
||||||
*/
|
*/
|
||||||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||||
".mvn/wrapper/maven-wrapper.properties";
|
".mvn/wrapper/maven-wrapper.properties";
|
||||||
|
|
||||||
/**
|
/** Path where the maven-wrapper.jar will be saved to. */
|
||||||
* Path where the maven-wrapper.jar will be saved to.
|
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";
|
||||||
*/
|
|
||||||
private static final String MAVEN_WRAPPER_JAR_PATH =
|
|
||||||
".mvn/wrapper/maven-wrapper.jar";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the property which should be used to override the default download url for the wrapper.
|
* Name of the property which should be used to override the default download url for the wrapper.
|
||||||
*/
|
*/
|
||||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("- Downloader started");
|
System.out.println("- Downloader started");
|
||||||
File baseDirectory = new File(args[0]);
|
File baseDirectory = new File(args[0]);
|
||||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||||
|
|
||||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||||
// wrapperUrl parameter.
|
// wrapperUrl parameter.
|
||||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||||
String url = DEFAULT_DOWNLOAD_URL;
|
String url = DEFAULT_DOWNLOAD_URL;
|
||||||
if (mavenWrapperPropertyFile.exists()) {
|
if (mavenWrapperPropertyFile.exists()) {
|
||||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||||
try {
|
try {
|
||||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||||
Properties mavenWrapperProperties = new Properties();
|
Properties mavenWrapperProperties = new Properties();
|
||||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
|
||||||
if (mavenWrapperPropertyFileInputStream != null) {
|
|
||||||
mavenWrapperPropertyFileInputStream.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
// Ignore ...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("- Downloading from: " + url);
|
|
||||||
|
|
||||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
|
||||||
if (!outputFile.getParentFile().exists()) {
|
|
||||||
if (!outputFile.getParentFile().mkdirs()) {
|
|
||||||
System.out.println(
|
|
||||||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
|
||||||
try {
|
try {
|
||||||
downloadFileFromURL(url, outputFile);
|
if (mavenWrapperPropertyFileInputStream != null) {
|
||||||
System.out.println("Done");
|
mavenWrapperPropertyFileInputStream.close();
|
||||||
System.exit(0);
|
}
|
||||||
} catch (Throwable e) {
|
} catch (IOException e) {
|
||||||
System.out.println("- Error downloading");
|
// Ignore ...
|
||||||
e.printStackTrace();
|
|
||||||
System.exit(1);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("- Downloading from: " + url);
|
||||||
|
|
||||||
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||||
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
if (!outputFile.getParentFile().exists()) {
|
||||||
String username = System.getenv("MVNW_USERNAME");
|
if (!outputFile.getParentFile().mkdirs()) {
|
||||||
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
System.out.println(
|
||||||
Authenticator.setDefault(new Authenticator() {
|
"- ERROR creating output directory '"
|
||||||
@Override
|
+ outputFile.getParentFile().getAbsolutePath()
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
+ "'");
|
||||||
return new PasswordAuthentication(username, password);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
URL website = new URL(urlString);
|
|
||||||
ReadableByteChannel rbc;
|
|
||||||
rbc = Channels.newChannel(website.openStream());
|
|
||||||
FileOutputStream fos = new FileOutputStream(destination);
|
|
||||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
|
||||||
fos.close();
|
|
||||||
rbc.close();
|
|
||||||
}
|
}
|
||||||
|
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||||
|
try {
|
||||||
|
downloadFileFromURL(url, outputFile);
|
||||||
|
System.out.println("Done");
|
||||||
|
System.exit(0);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
System.out.println("- Error downloading");
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||||
|
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
||||||
|
String username = System.getenv("MVNW_USERNAME");
|
||||||
|
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
||||||
|
Authenticator.setDefault(
|
||||||
|
new Authenticator() {
|
||||||
|
@Override
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(username, password);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
URL website = new URL(urlString);
|
||||||
|
ReadableByteChannel rbc;
|
||||||
|
rbc = Channels.newChannel(website.openStream());
|
||||||
|
FileOutputStream fos = new FileOutputStream(destination);
|
||||||
|
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||||
|
fos.close();
|
||||||
|
rbc.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
config/mvnw
vendored
8
config/mvnw
vendored
@@ -316,7 +316,7 @@ export MAVEN_CMD_LINE_ARGS
|
|||||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
exec "$JAVACMD" \
|
exec "$JAVACMD" \
|
||||||
$MAVEN_OPTS \
|
$MAVEN_OPTS \
|
||||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||||
|
|||||||
@@ -48,6 +48,8 @@
|
|||||||
<groupId>de.strasser.peter.hexagonal</groupId>
|
<groupId>de.strasser.peter.hexagonal</groupId>
|
||||||
<artifactId>persistence</artifactId>
|
<artifactId>persistence</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class HexagonalApplication {
|
public class HexagonalApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(HexagonalApplication.class, args);
|
SpringApplication.run(HexagonalApplication.class, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package de.strasser.peter.hexagonal.config;
|
||||||
|
|
||||||
|
public class ArchitectureTest {}
|
||||||
@@ -6,8 +6,6 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class HexagonalApplicationTests {
|
class HexagonalApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void contextLoads() {
|
void contextLoads() {}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
8
pom.xml
8
pom.xml
@@ -25,6 +25,7 @@
|
|||||||
<addressvalidation.version>0.0.1-SNAPSHOT</addressvalidation.version>
|
<addressvalidation.version>0.0.1-SNAPSHOT</addressvalidation.version>
|
||||||
<web.version>0.0.1-SNAPSHOT</web.version>
|
<web.version>0.0.1-SNAPSHOT</web.version>
|
||||||
<persistence.version>0.0.1-SNAPSHOT</persistence.version>
|
<persistence.version>0.0.1-SNAPSHOT</persistence.version>
|
||||||
|
<archunit.version>0.18.0</archunit.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@@ -77,6 +78,13 @@
|
|||||||
<artifactId>persistence</artifactId>
|
<artifactId>persistence</artifactId>
|
||||||
<version>${persistence.version}</version>
|
<version>${persistence.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tngtech.archunit</groupId>
|
||||||
|
<artifactId>archunit</artifactId>
|
||||||
|
<version>${archunit.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user