File tree Expand file tree Collapse file tree 16 files changed +147
-150
lines changed
main/java/com/example/consumingrest
test/java/com/example/consumingrest
customapplication/src/test/java/com/examplehub/customapplication
main/java/com/examplehub/custombanner
test/java/com/examplehub/custombanner
helloworld/src/test/java/com/examplehub/helloworld
main/java/com/examplehub/lazyinitialization
test/java/com/examplehub/lazyinitialization
main/java/com/example/restservice
test/java/com/example/restservice
main/java/com/examplehub/uploadfiles
test/java/com/examplehub/uploadfiles Expand file tree Collapse file tree 16 files changed +147
-150
lines changed Original file line number Diff line number Diff line change
1
+ name: Code Formatter
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ checkstyle:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - uses: actions/setup-python@v2
11
+ - name: Set up JDK 12
12
+ uses: actions/setup-java@v1
13
+ with:
14
+ java-version: 12
15
+ - run: wget https://github.com/google/google-java-format/releases/download/google-java-format-1.9/google-java-format-1.9-all-deps.jar -O formatter.jar
16
+ - run: java -jar formatter.jar --replace --set-exit-if-changed $(find . -type f -name "*.java" | grep ".*/src/.*java")
17
+ - name: Commit Format changes
18
+ if: failure()
19
+ run: |
20
+ git config --global user.name github-actions
21
+ git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
22
+ git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
23
+ git commit -am "Formatted with Google Java Formatter"
24
+ git push --force origin HEAD:$GITHUB_REF
Original file line number Diff line number Diff line change 12
12
@SpringBootApplication
13
13
public class ConsumingRestApplication {
14
14
15
- private static final Logger log = LoggerFactory.getLogger(ConsumingRestApplication.class);
15
+ private static final Logger log = LoggerFactory.getLogger(ConsumingRestApplication.class);
16
16
17
- public static void main(String[] args) {
18
- SpringApplication.run(ConsumingRestApplication.class, args);
19
- }
17
+ public static void main(String[] args) {
18
+ SpringApplication.run(ConsumingRestApplication.class, args);
19
+ }
20
20
21
- @Bean
22
- public RestTemplate restTemplate(RestTemplateBuilder builder) {
23
- return builder.build();
24
- }
21
+ @Bean
22
+ public RestTemplate restTemplate(RestTemplateBuilder builder) {
23
+ return builder.build();
24
+ }
25
25
26
- @Bean
27
- public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
28
- return args -> {
29
- Quote quote = restTemplate.getForObject(
30
- "https://gturnquist-quoters.cfapps.io/api/random", Quote.class);
31
- log.info(quote.toString());
32
- };
33
- }
26
+ @Bean
27
+ public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
28
+ return args -> {
29
+ Quote quote =
30
+ restTemplate.getForObject( "https://gturnquist-quoters.cfapps.io/api/random", Quote.class);
31
+ log.info(quote.toString());
32
+ };
33
+ }
34
34
}
Original file line number Diff line number Diff line change 5
5
@JsonIgnoreProperties(ignoreUnknown = true)
6
6
public class Quote {
7
7
8
- private String type;
9
- private Value value;
10
-
11
- public Quote() {
12
- }
13
-
14
- public String getType() {
15
- return type;
16
- }
17
-
18
- public void setType(String type) {
19
- this.type = type;
20
- }
21
-
22
- public Value getValue() {
23
- return value;
24
- }
25
-
26
- public void setValue(Value value) {
27
- this.value = value;
28
- }
29
-
30
- @Override
31
- public String toString() {
32
- return "Quote{" +
33
- "type='" + type + '\'' +
34
- ", value=" + value +
35
- '}';
36
- }
37
- }
8
+ private String type;
9
+ private Value value;
10
+
11
+ public Quote() {}
12
+
13
+ public String getType() {
14
+ return type;
15
+ }
16
+
17
+ public void setType(String type) {
18
+ this.type = type;
19
+ }
20
+
21
+ public Value getValue() {
22
+ return value;
23
+ }
24
+
25
+ public void setValue(Value value) {
26
+ this.value = value;
27
+ }
28
+
29
+ @Override
30
+ public String toString() {
31
+ return "Quote{" + "type='" + type + '\'' + ", value=" + value + '}';
32
+ }
33
+ }
Original file line number Diff line number Diff line change 5
5
@JsonIgnoreProperties(ignoreUnknown = true)
6
6
public class Value {
7
7
8
- private Long id;
9
- private String quote;
10
-
11
- public Value() {
12
- }
13
-
14
- public Long getId() {
15
- return this.id;
16
- }
17
-
18
- public String getQuote() {
19
- return this.quote;
20
- }
21
-
22
- public void setId(Long id) {
23
- this.id = id;
24
- }
25
-
26
- public void setQuote(String quote) {
27
- this.quote = quote;
28
- }
29
-
30
- @Override
31
- public String toString() {
32
- return "Value{" +
33
- "id=" + id +
34
- ", quote='" + quote + '\'' +
35
- '}';
36
- }
37
- }
8
+ private Long id;
9
+ private String quote;
10
+
11
+ public Value() {}
12
+
13
+ public Long getId() {
14
+ return this.id;
15
+ }
16
+
17
+ public String getQuote() {
18
+ return this.quote;
19
+ }
20
+
21
+ public void setId(Long id) {
22
+ this.id = id;
23
+ }
24
+
25
+ public void setQuote(String quote) {
26
+ this.quote = quote;
27
+ }
28
+
29
+ @Override
30
+ public String toString() {
31
+ return "Value{" + "id=" + id + ", quote='" + quote + '\'' + '}';
32
+ }
33
+ }
Original file line number Diff line number Diff line change 6
6
@SpringBootTest
7
7
class ConsumingRestApplicationTests {
8
8
9
- @Test
10
- void contextLoads() {
11
- }
12
-
9
+ @Test
10
+ void contextLoads() {}
13
11
}
Original file line number Diff line number Diff line change 6
6
@SpringBootTest
7
7
class CustomapplicationApplicationTests {
8
8
9
- @Test
10
- void contextLoads() {
11
- }
12
-
9
+ @Test
10
+ void contextLoads() {}
13
11
}
Original file line number Diff line number Diff line change 6
6
@SpringBootApplication
7
7
public class CustombannerApplication {
8
8
9
- public static void main(String[] args) {
10
- SpringApplication.run(CustombannerApplication.class, args);
11
- }
12
-
9
+ public static void main(String[] args) {
10
+ SpringApplication.run(CustombannerApplication.class, args);
11
+ }
13
12
}
Original file line number Diff line number Diff line change 6
6
@SpringBootTest
7
7
class CustombannerApplicationTests {
8
8
9
- @Test
10
- void contextLoads() {
11
- }
12
-
9
+ @Test
10
+ void contextLoads() {}
13
11
}
Original file line number Diff line number Diff line change 1
1
package com.examplehub.helloworld;
2
+
2
3
import static org.hamcrest.Matchers.equalTo;
3
4
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
4
5
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
5
6
6
7
import org.junit.jupiter.api.Test;
7
-
8
8
import org.springframework.beans.factory.annotation.Autowired;
9
9
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
10
10
import org.springframework.boot.test.context.SpringBootTest;
16
16
@AutoConfigureMockMvc
17
17
public class HomeControllerTests {
18
18
19
- @Autowired
20
- private MockMvc mvc;
19
+ @Autowired private MockMvc mvc;
21
20
22
- @Test
23
- public void getHello() throws Exception {
24
- mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.APPLICATION_JSON))
25
- .andExpect(status().isOk())
26
- .andExpect(content().string(equalTo("Hello World!")));
27
- }
21
+ @Test
22
+ public void getHello() throws Exception {
23
+ mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.APPLICATION_JSON))
24
+ .andExpect(status().isOk())
25
+ .andExpect(content().string(equalTo("Hello World!")));
26
+ }
28
27
}
Original file line number Diff line number Diff line change 1
1
package com.examplehub.lazyinitialization;
2
2
3
3
public class User {
4
- private String name;
5
- private int age;
4
+ private String name;
5
+ private int age;
6
6
7
- public User(String name, int age) {
8
- this.name = name;
9
- this.age = age;
7
+ public User(String name, int age) {
8
+ this.name = name;
9
+ this.age = age;
10
10
System.out.println(name + " initialized!");
11
- }
11
+ }
12
12
13
- public String getName() {
14
- return name;
15
- }
13
+ public String getName() {
14
+ return name;
15
+ }
16
16
17
- public void setName(String name) {
18
- this.name = name;
19
- }
17
+ public void setName(String name) {
18
+ this.name = name;
19
+ }
20
20
21
- public int getAge() {
22
- return age;
23
- }
21
+ public int getAge() {
22
+ return age;
23
+ }
24
24
25
- public void setAge(int age) {
26
- this.age = age;
27
- }
25
+ public void setAge(int age) {
26
+ this.age = age;
27
+ }
28
28
29
- @Override
30
- public String toString() {
31
- return "User{" +
32
- "name='" + name + '\'' +
33
- ", age=" + age +
34
- '}';
35
- }
29
+ @Override
30
+ public String toString() {
31
+ return "User{" + "name='" + name + '\'' + ", age=" + age + '}';
32
+ }
36
33
}
Original file line number Diff line number Diff line change 6
6
@SpringBootTest
7
7
class LazyinitializationApplicationTests {
8
8
9
- @Test
10
- void contextLoads() {
11
- }
12
-
9
+ @Test
10
+ void contextLoads() {}
13
11
}
Original file line number Diff line number Diff line change 1
1
package com.example.restservice;
2
2
3
+ import java.util.concurrent.atomic.AtomicLong;
3
4
import org.springframework.web.bind.annotation.RequestMapping;
4
5
import org.springframework.web.bind.annotation.RequestParam;
5
6
import org.springframework.web.bind.annotation.RestController;
6
7
7
- import java.util.concurrent.atomic.AtomicLong;
8
-
9
8
@RestController
10
9
public class GreetingController {
11
10
private final AtomicLong counter = new AtomicLong();
Original file line number Diff line number Diff line change 6
6
@SpringBootApplication
7
7
public class RestServiceApplication {
8
8
9
- public static void main(String[] args) {
10
- SpringApplication.run(RestServiceApplication.class, args);
11
- }
9
+ public static void main(String[] args) {
10
+ SpringApplication.run(RestServiceApplication.class, args);
11
+ }
12
12
}
Original file line number Diff line number Diff line change 6
6
@SpringBootTest
7
7
class RestServiceApplicationTests {
8
8
9
- @Test
10
- void contextLoads() {
11
- }
12
-
9
+ @Test
10
+ void contextLoads() {}
13
11
}
Original file line number Diff line number Diff line change 1
1
package com.examplehub.uploadfiles;
2
2
3
+ import java.io.File;
4
+ import java.nio.file.Files;
5
+ import java.nio.file.Path;
6
+ import java.nio.file.Paths;
7
+ import java.nio.file.StandardCopyOption;
8
+ import java.util.Objects;
3
9
import org.springframework.stereotype.Controller;
4
10
import org.springframework.util.StringUtils;
5
11
import org.springframework.web.bind.annotation.GetMapping;
8
14
import org.springframework.web.multipart.MultipartFile;
9
15
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
10
16
11
- import java.io.File;
12
- import java.nio.file.Files;
13
- import java.nio.file.Path;
14
- import java.nio.file.Paths;
15
- import java.nio.file.StandardCopyOption;
16
- import java.util.Objects;
17
-
18
17
@Controller
19
18
public class UploadController {
20
19
You can’t perform that action at this time.
0 commit comments