Skip to content

Commit 8335d2e

Browse files
rladdusawWilliam Wellingkaladay
authored
Tech debt upgrade (#101)
* Resolved syntax errors * Tests passing * Updated github workflow * Added javax to coveralls * add dockerfile and update pom * Update src/main/java/edu/tamu/app/config/AppH2ConsoleConfig.java Co-authored-by: Kevin Day <35114839+kaladay@users.noreply.github.com> * correct suggestion Co-authored-by: William Welling <8352733+wwelling@users.noreply.github.com> Co-authored-by: Kevin Day <35114839+kaladay@users.noreply.github.com>
1 parent 1f3505e commit 8335d2e

42 files changed

Lines changed: 622 additions & 500 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Whitespace-only changes.

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818
- name: "Setup Java"
1919
uses: actions/setup-java@v1
2020
with:
21-
java-version: 1.8
21+
java-version: 11
2222

2323
- name: "Maven Test"
24-
run: mvn clean test cobertura:cobertura jacoco:report coveralls:report -DdryRun=true
24+
run: mvn clean test jacoco:report coveralls:report -DdryRun=true
2525

2626
- name: "Send to Coveralls (build java-${{ github.run_number }})"
2727
uses: MikeEdgar/github-action@raw_coverage_file

Dockerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Settings.
2+
ARG USER_ID=3001
3+
ARG USER_NAME=lsss
4+
ARG HOME_DIR=/$USER_NAME
5+
ARG SOURCE_DIR=$HOME_DIR/source
6+
7+
# Maven stage.
8+
FROM maven:3-openjdk-11-slim as maven
9+
ARG USER_ID
10+
ARG USER_NAME
11+
ARG HOME_DIR
12+
ARG SOURCE_DIR
13+
14+
# Create the group (use a high ID to attempt to avoid conflits).
15+
RUN groupadd -g $USER_ID $USER_NAME
16+
17+
# Create the user (use a high ID to attempt to avoid conflits).
18+
RUN useradd -d $HOME_DIR -m -u $USER_ID -g $USER_ID $USER_NAME
19+
20+
# Update the system.
21+
RUN apt-get update && apt-get upgrade -y
22+
23+
# Set deployment directory.
24+
WORKDIR $SOURCE_DIR
25+
26+
# Copy files over.
27+
COPY ./pom.xml ./pom.xml
28+
COPY ./src ./src
29+
30+
# Assign file permissions.
31+
RUN chown -R ${USER_ID}:${USER_ID} ${SOURCE_DIR}
32+
33+
# Login as user.
34+
USER $USER_NAME
35+
36+
# Build.
37+
RUN mvn package -Pjar -DskipTests=true
38+
39+
# Switch to Normal JRE Stage.
40+
FROM openjdk:11-jre-slim
41+
ARG USER_ID
42+
ARG USER_NAME
43+
ARG HOME_DIR
44+
ARG SOURCE_DIR
45+
46+
# Create the group (use a high ID to attempt to avoid conflits).
47+
RUN groupadd -g $USER_ID $USER_NAME
48+
49+
# Create the user (use a high ID to attempt to avoid conflits).
50+
RUN useradd -d $HOME_DIR -m -u $USER_ID -g $USER_ID $USER_NAME
51+
52+
# Login as user.
53+
USER $USER_NAME
54+
55+
# Set deployment directory.
56+
WORKDIR $HOME_DIR
57+
58+
# Copy over the built artifact from the maven image.
59+
COPY --from=maven $SOURCE_DIR/target/ROOT.jar ./lsss.jar
60+
61+
62+
# Run java command.
63+
CMD ["java", "-jar", "./lsss.jar"]

pom.xml

Lines changed: 83 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,57 @@
1111
<parent>
1212
<groupId>edu.tamu.weaver</groupId>
1313
<artifactId>webservice-parent</artifactId>
14-
<version>2.0.2</version>
14+
<version>2.1.1-RC10</version>
1515
</parent>
1616

1717
<properties>
18-
<log4j2.version>2.16.0</log4j2.version>
18+
<java.version>11</java.version>
19+
<log4j2.version>2.16.0</log4j2.version>
20+
<maven.packaging>war</maven.packaging>
21+
<maven-plugins.version>2.22.2</maven-plugins.version>
1922
</properties>
2023

21-
<packaging>war</packaging>
24+
<packaging>${maven.packaging}</packaging>
25+
26+
<profiles>
27+
<profile>
28+
<id>war</id>
29+
<properties>
30+
<maven.packaging>war</maven.packaging>
31+
</properties>
32+
</profile>
33+
<profile>
34+
<id>jar</id>
35+
<properties>
36+
<maven.packaging>jar</maven.packaging>
37+
</properties>
38+
</profile>
39+
</profiles>
2240

2341
<dependencies>
2442

2543
<dependency>
2644
<groupId>edu.tamu.weaver</groupId>
2745
<artifactId>auth</artifactId>
28-
<version>2.0.2</version>
46+
<version>${project.parent.version}</version>
2947
</dependency>
3048

3149
<dependency>
3250
<groupId>edu.tamu.weaver</groupId>
3351
<artifactId>token-provider</artifactId>
34-
<version>2.0.2</version>
52+
<version>${project.parent.version}</version>
3553
</dependency>
3654

3755
<dependency>
3856
<groupId>edu.tamu.weaver</groupId>
3957
<artifactId>validation</artifactId>
40-
<version>2.0.2</version>
58+
<version>${project.parent.version}</version>
4159
</dependency>
4260

4361
<dependency>
4462
<groupId>edu.tamu.weaver</groupId>
4563
<artifactId>reporting</artifactId>
46-
<version>2.0.2</version>
47-
</dependency>
48-
49-
<dependency>
50-
<groupId>org.postgresql</groupId>
51-
<artifactId>postgresql</artifactId>
64+
<version>${project.parent.version}</version>
5265
</dependency>
5366

5467
<dependency>
@@ -81,46 +94,42 @@
8194

8295
<dependency>
8396
<groupId>org.mockito</groupId>
84-
<artifactId>mockito-all</artifactId>
85-
<version>1.10.19</version>
97+
<artifactId>mockito-core</artifactId>
8698
<scope>test</scope>
8799
</dependency>
88100

89-
</dependencies>
101+
<dependency>
102+
<groupId>org.mockito</groupId>
103+
<artifactId>mockito-junit-jupiter</artifactId>
104+
<scope>test</scope>
105+
</dependency>
90106

107+
</dependencies>
108+
91109
<build>
92110
<finalName>ROOT</finalName>
93111
<plugins>
94112
<plugin>
95113
<groupId>org.springframework.boot</groupId>
96114
<artifactId>spring-boot-maven-plugin</artifactId>
115+
<executions>
116+
<execution>
117+
<goals>
118+
<goal>repackage</goal>
119+
</goals>
120+
</execution>
121+
</executions>
97122
</plugin>
123+
98124
<plugin>
99125
<groupId>org.apache.maven.plugins</groupId>
100126
<artifactId>maven-war-plugin</artifactId>
101-
<version>3.2.0</version>
127+
<version>3.2.2</version>
102128
<configuration>
103129
<failOnMissingWebXml>false</failOnMissingWebXml>
104130
</configuration>
105131
</plugin>
106-
<plugin>
107-
<groupId>org.codehaus.mojo</groupId>
108-
<artifactId>cobertura-maven-plugin</artifactId>
109-
<configuration>
110-
<quiet>true</quiet>
111-
<instrumentation>
112-
<ignoreTrivial>true</ignoreTrivial>
113-
<ignores>
114-
<ignore>java.util.logging.*</ignore>
115-
</ignores>
116-
</instrumentation>
117-
<formats>
118-
<format>html</format>
119-
<format>xml</format>
120-
</formats>
121-
<aggregate>true</aggregate>
122-
</configuration>
123-
</plugin>
132+
124133
<plugin>
125134
<groupId>org.jacoco</groupId>
126135
<artifactId>jacoco-maven-plugin</artifactId>
@@ -133,22 +142,60 @@
133142
</execution>
134143
</executions>
135144
</plugin>
145+
136146
<plugin>
137147
<groupId>org.eluder.coveralls</groupId>
138148
<artifactId>coveralls-maven-plugin</artifactId>
139149
<configuration>
140150
<repoToken></repoToken>
141151
</configuration>
152+
<dependencies>
153+
<dependency>
154+
<groupId>javax.xml.bind</groupId>
155+
<artifactId>jaxb-api</artifactId>
156+
<version>2.3.1</version>
157+
</dependency>
158+
</dependencies>
159+
</plugin>
160+
161+
<plugin>
162+
<groupId>org.apache.maven.plugins</groupId>
163+
<artifactId>maven-surefire-plugin</artifactId>
164+
<version>${maven-plugins.version}</version>
142165
</plugin>
166+
167+
<plugin>
168+
<groupId>org.apache.maven.plugins</groupId>
169+
<artifactId>maven-failsafe-plugin</artifactId>
170+
<version>${maven-plugins.version}</version>
171+
</plugin>
172+
143173
</plugins>
174+
175+
<resources>
176+
<resource>
177+
<directory>src/main/resources</directory>
178+
<filtering>true</filtering>
179+
<includes>
180+
<include>application.properties</include>
181+
</includes>
182+
<excludes>
183+
<exclude>**/*.jks</exclude>
184+
</excludes>
185+
</resource>
186+
<resource>
187+
<directory>src/main/resources</directory>
188+
</resource>
189+
</resources>
190+
144191
</build>
192+
145193
<reporting>
146-
<outputDirectory>${project.build.directory}/site</outputDirectory>
147194
<plugins>
148195
<plugin>
149196
<groupId>org.apache.maven.plugins</groupId>
150197
<artifactId>maven-project-info-reports-plugin</artifactId>
151-
<version>2.7</version>
198+
<version>3.3.0</version>
152199
<configuration>
153200
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
154201
</configuration>

src/main/java/edu/tamu/app/StatusApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.boot.builder.SpringApplicationBuilder;
6-
import org.springframework.boot.web.support.SpringBootServletInitializer;
6+
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
77
import org.springframework.context.annotation.ComponentScan;
88
import org.springframework.scheduling.annotation.EnableScheduling;
99

src/main/java/edu/tamu/app/config/AppH2ConsoleConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
public class AppH2ConsoleConfig {
1212

1313
@Bean
14-
public ServletRegistrationBean h2servletRegistration() {
15-
ServletRegistrationBean registrationBean = new ServletRegistrationBean(new WebServlet());
14+
public ServletRegistrationBean<WebServlet> h2servletRegistration() {
15+
ServletRegistrationBean<WebServlet> registrationBean = new ServletRegistrationBean<>(new WebServlet());
1616
registrationBean.addUrlMappings("/admin/h2console/*");
1717
registrationBean.addInitParameter("-webAllowOthers", "true");
1818
return registrationBean;

src/main/java/edu/tamu/app/config/AppWebMvcConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
1616
import org.springframework.web.servlet.config.annotation.CorsRegistry;
1717
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
18-
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
18+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
1919
import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
2020

2121
import edu.tamu.app.model.User;
@@ -28,7 +28,7 @@
2828
@Configuration
2929
@EntityScan(basePackages = { "edu.tamu.app.model" })
3030
@EnableJpaRepositories(basePackages = { "edu.tamu.app.model.repo" })
31-
public class AppWebMvcConfig extends WebMvcConfigurerAdapter {
31+
public class AppWebMvcConfig implements WebMvcConfigurer {
3232

3333
@Value("${app.security.allow-access}")
3434
private String[] hosts;

src/main/java/edu/tamu/app/config/AppWebSocketConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import org.springframework.context.annotation.Configuration;
44
import org.springframework.messaging.simp.config.ChannelRegistration;
55
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
6-
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
76
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
87
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
8+
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
99
import org.springframework.web.socket.config.annotation.WebSocketTransportRegistration;
1010

1111
/**
@@ -16,7 +16,7 @@
1616
*/
1717
@Configuration
1818
@EnableWebSocketMessageBroker
19-
public class AppWebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
19+
public class AppWebSocketConfig implements WebSocketMessageBrokerConfigurer {
2020

2121
/**
2222
* {@inheritDoc}

src/main/java/edu/tamu/app/controller/FeatureProposalController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public ApiResponse getAllFeatureProposalsByService(@RequestBody FilteredPageRequ
4141
@RequestMapping("/{id}")
4242
@PreAuthorize("hasRole('SERVICE_MANAGER')")
4343
public ApiResponse getFeatureProposal(@PathVariable Long id) {
44-
return new ApiResponse(SUCCESS, featureProposalRepo.findOne(id));
44+
return new ApiResponse(SUCCESS, featureProposalRepo.getById(id));
4545
}
4646

4747
@RequestMapping("/create")
@@ -86,7 +86,7 @@ public ApiResponse remove(@WeaverValidatedModel FeatureProposal featureProposal)
8686
@RequestMapping("/{id}/vote")
8787
@PreAuthorize("hasRole('USER')")
8888
public ApiResponse vote(@PathVariable Long id, @WeaverUser User voter) {
89-
FeatureProposal featureProposal = featureProposalRepo.findOne(id);
89+
FeatureProposal featureProposal = featureProposalRepo.getById(id);
9090
featureProposal.addVoter(voter);
9191
return new ApiResponse(SUCCESS, featureProposalRepo.update(featureProposal));
9292
}

src/main/java/edu/tamu/app/controller/IdeaController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public ApiResponse page(@RequestBody FilteredPageRequest filteredPageRequest) {
4444
@RequestMapping("/{id}")
4545
@PreAuthorize("hasRole('SERVICE_MANAGER')")
4646
public ApiResponse getById(@PathVariable Long id) {
47-
return new ApiResponse(SUCCESS, ideaRepo.findOne(id));
47+
return new ApiResponse(SUCCESS, ideaRepo.getById(id));
4848
}
4949

5050
@RequestMapping("/create")

0 commit comments

Comments
 (0)