Skip to content

Commit 2cae9fe

Browse files
initial commit
0 parents  commit 2cae9fe

20 files changed

+737
-0
lines changed

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### IntelliJ IDEA ###
7+
.idea/modules.xml
8+
.idea/jarRepositories.xml
9+
.idea/compiler.xml
10+
.idea/libraries/
11+
*.iws
12+
*.iml
13+
*.ipr
14+
15+
### Eclipse ###
16+
.apt_generated
17+
.classpath
18+
.factorypath
19+
.project
20+
.settings
21+
.springBeans
22+
.sts4-cache
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
build/
31+
!**/src/main/**/build/
32+
!**/src/test/**/build/
33+
34+
### VS Code ###
35+
.vscode/
36+
37+
### Mac OS ###
38+
.DS_Store

.idea/.gitignore

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.amigoscode</groupId>
6+
<artifactId>unit-testing</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
10+
<name>unit-testing</name>
11+
<url>http://maven.apache.org</url>
12+
13+
<properties>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.junit.jupiter</groupId>
20+
<artifactId>junit-jupiter</artifactId>
21+
<version>5.11.4</version>
22+
<scope>test</scope>
23+
</dependency>
24+
25+
<dependency>
26+
<groupId>org.assertj</groupId>
27+
<artifactId>assertj-core</artifactId>
28+
<version>3.27.2</version>
29+
<scope>test</scope>
30+
</dependency>
31+
32+
</dependencies>
33+
<build>
34+
<plugins>
35+
<plugin>
36+
<groupId>org.apache.maven.plugins</groupId>
37+
<artifactId>maven-compiler-plugin</artifactId>
38+
<configuration>
39+
<source>21</source>
40+
<target>21</target>
41+
<compilerArgs>--enable-preview</compilerArgs>
42+
</configuration>
43+
</plugin>
44+
</plugins>
45+
</build>
46+
</project>

src/main/java/com/amigoscode/App.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.amigoscode;
2+
3+
public class App {
4+
public static void main(String[] args) {
5+
System.out.println("Hello World!");
6+
}
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.amigoscode;
2+
3+
public class Calculator {
4+
5+
public <T extends Number> double add(T a, T b) {
6+
return a.doubleValue() + b.doubleValue();
7+
}
8+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.amigoscode;
2+
3+
import java.util.function.Predicate;
4+
import java.util.regex.Pattern;
5+
6+
public class EmailValidator implements Predicate<String> {
7+
private static final Pattern EMAIL_PATTERN = Pattern.compile(
8+
"^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$"
9+
);
10+
11+
@Override
12+
public boolean test(String email) {
13+
return email != null &&
14+
EMAIL_PATTERN.matcher(email).matches();
15+
}
16+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.amigoscode;
2+
3+
import java.util.function.Predicate;
4+
5+
public class PasswordValidator implements Predicate<String> {
6+
7+
private static final int MIN_PASSWORD_CHAR_LENGTH = 8;
8+
private static final String DIGIT_REGEX = ".*\\d.*";
9+
private static final String SPECIAL_CHAR_REGEX = ".*[!@#$%^&*()_+=<>?/\\[\\]{}|].*";
10+
11+
@Override
12+
public boolean test(String password) {
13+
if(password == null || password.trim().isBlank()) {
14+
return false;
15+
}
16+
17+
password = password.trim();
18+
19+
if(password.length() < MIN_PASSWORD_CHAR_LENGTH) {
20+
return false;
21+
}
22+
23+
if(!password.matches(DIGIT_REGEX)) {
24+
return false;
25+
}
26+
27+
if (!password.matches(SPECIAL_CHAR_REGEX)) {
28+
return false;
29+
}
30+
31+
return true;
32+
}
33+
}

0 commit comments

Comments
 (0)