Skip to content

Commit 1f97996

Browse files
Merge pull request aws-samples#8 from pdineshbalaaji/change-branch
Change branch
2 parents f8627a5 + b2e0889 commit 1f97996

File tree

13 files changed

+149
-37
lines changed

13 files changed

+149
-37
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
.classpath
66
.project
77
.settings/
8+
/movie-service-utils/jars/
89

910
# Packaged files #
10-
*.jar
11+
#*.jar
1112
*.war
1213
*.ear
1314
*.iml
15+
Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
1-
id: no-unused-vars
1+
id: sysout-to-logger
22
language: java
33
rule:
4-
kind: local_variable_declaration
5-
all:
6-
- has:
7-
has:
8-
kind: identifier
9-
pattern: $IDENT
10-
- not:
11-
precedes:
12-
stopBy: end
13-
has:
14-
stopBy: end
15-
any:
16-
- { kind: identifier, pattern: $IDENT }
17-
- { has: {kind: identifier, pattern: $IDENT, stopBy: end}}
18-
fix: ''
4+
pattern: System.out.println($MATCH)
5+
fix: logger.info($MATCH)
6+
7+
--- # this is YAML doc separator to have multiple rules in one file
8+
9+
id: update-movie-service-util-java17
10+
language: html
11+
rule:
12+
pattern: |-
13+
<dependency>
14+
<groupId>org.amazonaws.samples</groupId>
15+
<artifactId>movie-service-utils</artifactId>
16+
<version>$VERSION</version>
17+
</dependency>
18+
constraints:
19+
VERSION:
20+
regex: "^0\\.1\\.0"
21+
fix: |-
22+
<dependency>
23+
<groupId>org.amazonaws.samples</groupId>
24+
<artifactId>movie-service-utils</artifactId>
25+
<version>0.2.0</version>
26+
</dependency>
27+
28+
--- # this is YAML doc separator to have multiple rules in one file
29+
id: update-movie-service-util-method
30+
language: java
31+
rule:
32+
pattern: |-
33+
MovieUtils.isValidMovieName($MOVIE_NAME)
34+
fix: |-
35+
MovieUtils.isValidMovie($MOVIE_NAME, movieId)

custom-transformation-pre-qct.yaml

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
1-
id: sysout-to-logger
1+
id: no-unused-vars
22
language: java
33
rule:
4-
pattern: System.out.println($MATCH)
5-
fix: logger.info($MATCH)
6-
#rule:
7-
# kind: local_variable_declaration
8-
# all:
9-
# - has:
10-
# has:
11-
# kind: identifier
12-
# pattern: $IDENT
13-
# - not:
14-
# precedes:
15-
# stopBy: end
16-
# has:
17-
# stopBy: end
18-
# any:
19-
# - { kind: identifier, pattern: $IDENT }
20-
# - { has: {kind: identifier, pattern: $IDENT, stopBy: end}}
21-
#fix: ''vi
4+
kind: local_variable_declaration
5+
all:
6+
- has:
7+
has:
8+
kind: identifier
9+
pattern: $IDENT
10+
- not:
11+
precedes:
12+
stopBy: end
13+
has:
14+
stopBy: end
15+
any:
16+
- { kind: identifier, pattern: $IDENT }
17+
- { has: {kind: identifier, pattern: $IDENT, stopBy: end}}
18+
fix: ''
19+
20+
--- # this is YAML doc separator to have multiple rules in one file
21+
22+
id: no-unused-imports
23+
language: java
24+
rule:
25+
kind: import_declaration
26+
all:
27+
- not:
28+
has:
29+
kind: asterisk
30+
- has:
31+
has:
32+
kind: identifier
33+
pattern: $IDENT
34+
- not:
35+
precedes:
36+
stopBy: end
37+
has:
38+
stopBy: end
39+
any:
40+
- { kind: identifier, pattern: $IDENT }
41+
- { kind: type_identifier, pattern: $IDENT }
42+
- { has: {kind: type_identifier, pattern: $IDENT, stopBy: end}}
43+
fix: ''
Binary file not shown.
Binary file not shown.

movie-service-utils/pom.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>org.amazonaws.samples</groupId>
6+
<artifactId>movie-service-utils</artifactId>
7+
<version>0.2.0</version>
8+
9+
<properties>
10+
<java.version>17</java.version>
11+
<maven.compiler.source>17</maven.compiler.source>
12+
<maven.compiler.target>17</maven.compiler.target>
13+
<maven.compiler.release>17</maven.compiler.release>
14+
</properties>
15+
16+
<dependencies>
17+
<!-- Add any dependencies needed for the utils module -->
18+
</dependencies>
19+
20+
<build>
21+
<plugins>
22+
<plugin>
23+
<groupId>org.apache.maven.plugins</groupId>
24+
<artifactId>maven-compiler-plugin</artifactId>
25+
<version>3.13.0</version>
26+
<configuration>
27+
<release>${java.version}</release>
28+
</configuration>
29+
</plugin>
30+
</plugins>
31+
</build>
32+
</project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.amazonaws.samples.appconfig.utils;
2+
3+
public class MovieUtils {
4+
5+
/**
6+
* Validates if a movie name meets the required criteria
7+
* @param movieName The name of the movie to validate
8+
* @return true if the movie name is valid, false otherwise
9+
*/
10+
public static boolean isValidMovie(String movieName, int movieId) {
11+
if (movieName == null || movieName.trim().isEmpty()) {
12+
return false;
13+
}
14+
15+
if(movieId <= 0){
16+
return false;
17+
}
18+
// Movie name should be between 1 and 200 characters
19+
return movieName.trim().length() > 0 && movieName.trim().length() <= 200;
20+
}
21+
}
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
artifactId=movie-service-utils
2+
groupId=org.springframework
3+
version=0.2.0

pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55

6-
<groupId>org.springframework</groupId>
6+
<groupId>org.amazonaws.samples</groupId>
77
<artifactId>movie-service</artifactId>
88
<version>0.1.0</version>
99

@@ -25,6 +25,11 @@
2525
</dependencyManagement>
2626

2727
<dependencies>
28+
<dependency>
29+
<groupId>org.amazonaws.samples</groupId>
30+
<artifactId>movie-service-utils</artifactId>
31+
<version>0.1.0</version>
32+
</dependency>
2833
<dependency>
2934
<groupId>org.springframework.boot</groupId>
3035
<artifactId>spring-boot-starter-web</artifactId>

0 commit comments

Comments
 (0)