Skip to content

Commit da0cd15

Browse files
committed
Reformat code style
1 parent 25cb16d commit da0cd15

23 files changed

Lines changed: 261 additions & 286 deletions

‎dependency-injection/pom.xml‎

Lines changed: 76 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,83 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0"
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44

5-
<modelVersion>4.0.0</modelVersion>
5+
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>com.baeldung</groupId>
8-
<artifactId>dependency-injection</artifactId>
9-
<version>0.0.1-SNAPSHOT</version>
10-
<packaging>war</packaging>
7+
<groupId>com.baeldung</groupId>
8+
<artifactId>dependency-injection</artifactId>
9+
<version>0.0.1-SNAPSHOT</version>
10+
<packaging>war</packaging>
1111

12-
<name>Resource vs Inject vs Autowired</name>
13-
<description>Accompanying the demonstration of the use of the annotations related to injection mechanisms, namely Resource, Inject, and Autowired</description>
12+
<name>Resource vs Inject vs Autowired</name>
13+
<description>Accompanying the demonstration of the use of the annotations related to injection mechanisms, namely
14+
Resource, Inject, and Autowired
15+
</description>
1416

15-
<dependencies>
16-
<dependency>
17-
<groupId>junit</groupId>
18-
<artifactId>junit</artifactId>
19-
<version>4.11</version>
20-
<scope>test</scope>
21-
</dependency>
22-
<dependency>
23-
<groupId>org.mockito</groupId>
24-
<artifactId>mockito-all</artifactId>
25-
<version>1.10.19</version>
26-
</dependency>
27-
<dependency>
28-
<groupId>org.springframework</groupId>
29-
<artifactId>spring-test</artifactId>
30-
<version>4.2.6.RELEASE</version>
31-
</dependency>
32-
<dependency>
33-
<groupId>org.springframework</groupId>
34-
<artifactId>spring-core</artifactId>
35-
<version>4.2.6.RELEASE</version>
36-
</dependency>
37-
<dependency>
38-
<groupId>org.springframework</groupId>
39-
<artifactId>spring-beans</artifactId>
40-
<version>4.2.6.RELEASE</version>
41-
</dependency>
42-
<dependency>
43-
<groupId>org.springframework</groupId>
44-
<artifactId>spring-context</artifactId>
45-
<version>4.2.6.RELEASE</version>
46-
</dependency>
47-
<dependency>
48-
<groupId>javax.inject</groupId>
49-
<artifactId>javax.inject</artifactId>
50-
<version>1</version>
51-
</dependency>
52-
</dependencies>
17+
<dependencies>
18+
<dependency>
19+
<groupId>junit</groupId>
20+
<artifactId>junit</artifactId>
21+
<version>4.11</version>
22+
<scope>test</scope>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.mockito</groupId>
26+
<artifactId>mockito-all</artifactId>
27+
<version>1.10.19</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.springframework</groupId>
31+
<artifactId>spring-test</artifactId>
32+
<version>4.2.6.RELEASE</version>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.springframework</groupId>
36+
<artifactId>spring-core</artifactId>
37+
<version>4.2.6.RELEASE</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.springframework</groupId>
41+
<artifactId>spring-beans</artifactId>
42+
<version>4.2.6.RELEASE</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.springframework</groupId>
46+
<artifactId>spring-context</artifactId>
47+
<version>4.2.6.RELEASE</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>javax.inject</groupId>
51+
<artifactId>javax.inject</artifactId>
52+
<version>1</version>
53+
</dependency>
54+
</dependencies>
5355

54-
<build>
55-
<plugins>
56-
<plugin>
57-
<artifactId>maven-compiler-plugin</artifactId>
58-
<configuration>
59-
<source>1.8</source>
60-
<target>1.8</target>
61-
</configuration>
62-
</plugin>
63-
<plugin>
64-
<groupId>org.apache.maven.plugins</groupId>
65-
<artifactId>maven-surefire-plugin</artifactId>
66-
<configuration>
67-
<includes>
68-
<include>**/*Test.java</include>
69-
</includes>
70-
</configuration>
71-
</plugin>
72-
</plugins>
73-
</build>
56+
<build>
57+
<plugins>
58+
<plugin>
59+
<artifactId>maven-compiler-plugin</artifactId>
60+
<configuration>
61+
<source>1.8</source>
62+
<target>1.8</target>
63+
</configuration>
64+
</plugin>
65+
<plugin>
66+
<groupId>org.apache.maven.plugins</groupId>
67+
<artifactId>maven-surefire-plugin</artifactId>
68+
<configuration>
69+
<includes>
70+
<include>**/*Test.java</include>
71+
</includes>
72+
</configuration>
73+
</plugin>
74+
</plugins>
75+
</build>
7476

75-
<repositories>
76-
<repository>
77-
<id>java.net</id>
78-
<url>https://maven.java.net/content/repositories/releases/</url>
79-
</repository>
80-
</repositories>
77+
<repositories>
78+
<repository>
79+
<id>java.net</id>
80+
<url>https://maven.java.net/content/repositories/releases/</url>
81+
</repository>
82+
</repositories>
8183
</project>
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
package com.baeldung.autowired;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertNotNull;
5-
3+
import com.baeldung.configuration.ApplicationContextTestAutowiredName;
4+
import com.baeldung.dependency.ArbitraryDependency;
65
import org.junit.Test;
76
import org.junit.runner.RunWith;
87
import org.springframework.beans.factory.annotation.Autowired;
98
import org.springframework.test.context.ContextConfiguration;
109
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
1110
import org.springframework.test.context.support.AnnotationConfigContextLoader;
1211

13-
import com.baeldung.configuration.ApplicationContextTestAutowiredName;
14-
import com.baeldung.dependency.ArbitraryDependency;
12+
import static org.junit.Assert.assertEquals;
13+
import static org.junit.Assert.assertNotNull;
1514

1615
@RunWith(SpringJUnit4ClassRunner.class)
1716
@ContextConfiguration(
18-
loader=AnnotationConfigContextLoader.class,
19-
classes=ApplicationContextTestAutowiredName.class)
17+
loader = AnnotationConfigContextLoader.class,
18+
classes = ApplicationContextTestAutowiredName.class)
2019
public class FieldAutowiredNameTest {
2120

2221
@Autowired
2322
private ArbitraryDependency autowiredFieldDependency;
2423

2524
@Test
26-
public void givenAutowiredAnnotation_WhenOnField_ThenDependencyValid(){
25+
public void givenAutowiredAnnotation_WhenOnField_ThenDependencyValid() {
2726
assertNotNull(autowiredFieldDependency);
28-
assertEquals("Arbitrary Dependency",
29-
autowiredFieldDependency.toString());
30-
}
27+
assertEquals("Arbitrary Dependency", autowiredFieldDependency.toString());
28+
}
3129
}

‎dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredTest.java‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
package com.baeldung.autowired;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertNotNull;
5-
3+
import com.baeldung.configuration.ApplicationContextTestAutowiredType;
4+
import com.baeldung.dependency.ArbitraryDependency;
65
import org.junit.Test;
76
import org.junit.runner.RunWith;
87
import org.springframework.beans.factory.annotation.Autowired;
98
import org.springframework.test.context.ContextConfiguration;
109
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
1110
import org.springframework.test.context.support.AnnotationConfigContextLoader;
1211

13-
import com.baeldung.configuration.ApplicationContextTestAutowiredType;
14-
import com.baeldung.dependency.ArbitraryDependency;
12+
import static org.junit.Assert.assertEquals;
13+
import static org.junit.Assert.assertNotNull;
1514

1615
@RunWith(SpringJUnit4ClassRunner.class)
1716
@ContextConfiguration(
18-
loader=AnnotationConfigContextLoader.class,
19-
classes=ApplicationContextTestAutowiredType.class)
17+
loader = AnnotationConfigContextLoader.class,
18+
classes = ApplicationContextTestAutowiredType.class)
2019
public class FieldAutowiredTest {
2120

2221
@Autowired
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.baeldung.autowired;
22

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertNotNull;
5-
3+
import com.baeldung.configuration.ApplicationContextTestAutowiredQualifier;
4+
import com.baeldung.dependency.ArbitraryDependency;
65
import org.junit.Test;
76
import org.junit.runner.RunWith;
87
import org.springframework.beans.factory.annotation.Autowired;
@@ -11,13 +10,13 @@
1110
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
1211
import org.springframework.test.context.support.AnnotationConfigContextLoader;
1312

14-
import com.baeldung.configuration.ApplicationContextTestAutowiredQualifier;
15-
import com.baeldung.dependency.ArbitraryDependency;
13+
import static org.junit.Assert.assertEquals;
14+
import static org.junit.Assert.assertNotNull;
1615

1716
@RunWith(SpringJUnit4ClassRunner.class)
1817
@ContextConfiguration(
19-
loader=AnnotationConfigContextLoader.class,
20-
classes=ApplicationContextTestAutowiredQualifier.class)
18+
loader = AnnotationConfigContextLoader.class,
19+
classes = ApplicationContextTestAutowiredQualifier.class)
2120
public class FieldQualifierAutowiredTest {
2221

2322
@Autowired
@@ -29,15 +28,14 @@ public class FieldQualifierAutowiredTest {
2928
private ArbitraryDependency fieldDependency2;
3029

3130
@Test
32-
public void givenAutowiredQualifier_WhenOnField_ThenDep1Valid(){
31+
public void givenAutowiredQualifier_WhenOnField_ThenDep1Valid() {
3332
assertNotNull(fieldDependency1);
3433
assertEquals("Arbitrary Dependency", fieldDependency1.toString());
3534
}
3635

3736
@Test
38-
public void givenAutowiredQualifier_WhenOnField_ThenDep2Valid(){
37+
public void givenAutowiredQualifier_WhenOnField_ThenDep2Valid() {
3938
assertNotNull(fieldDependency2);
40-
assertEquals("Another Arbitrary Dependency",
41-
fieldDependency2.toString());
39+
assertEquals("Another Arbitrary Dependency", fieldDependency2.toString());
4240
}
4341
}

‎dependency-injection/src/test/java/com/baeldung/configuration/ApplicationContextTestAutowiredName.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
import org.springframework.context.annotation.Configuration;
55

66
@Configuration
7-
@ComponentScan(basePackages={"com.baeldung.dependency"})
7+
@ComponentScan(basePackages = {"com.baeldung.dependency"})
88
public class ApplicationContextTestAutowiredName {
99
}
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
package com.baeldung.configuration;
22

3-
import org.springframework.context.annotation.Bean;
4-
import org.springframework.context.annotation.Configuration;
5-
63
import com.baeldung.dependency.AnotherArbitraryDependency;
74
import com.baeldung.dependency.ArbitraryDependency;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
87

98
@Configuration
109
public class ApplicationContextTestAutowiredQualifier {
1110

12-
@Bean
13-
public ArbitraryDependency autowiredFieldDependency() {
14-
ArbitraryDependency autowiredFieldDependency = new ArbitraryDependency();
11+
@Bean
12+
public ArbitraryDependency autowiredFieldDependency() {
13+
ArbitraryDependency autowiredFieldDependency = new ArbitraryDependency();
1514

16-
return autowiredFieldDependency;
17-
}
15+
return autowiredFieldDependency;
16+
}
1817

19-
@Bean
20-
public ArbitraryDependency anotherAutowiredFieldDependency() {
21-
ArbitraryDependency anotherAutowiredFieldDependency = new AnotherArbitraryDependency();
18+
@Bean
19+
public ArbitraryDependency anotherAutowiredFieldDependency() {
20+
ArbitraryDependency anotherAutowiredFieldDependency = new AnotherArbitraryDependency();
2221

23-
return anotherAutowiredFieldDependency;
24-
}
22+
return anotherAutowiredFieldDependency;
23+
}
2524
}

‎dependency-injection/src/test/java/com/baeldung/configuration/ApplicationContextTestAutowiredType.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.baeldung.configuration;
22

3+
import com.baeldung.dependency.ArbitraryDependency;
34
import org.springframework.context.annotation.Bean;
45
import org.springframework.context.annotation.Configuration;
56

6-
import com.baeldung.dependency.ArbitraryDependency;
7-
87
@Configuration
98
public class ApplicationContextTestAutowiredType {
109

‎dependency-injection/src/test/java/com/baeldung/configuration/ApplicationContextTestInjectName.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.baeldung.configuration;
22

3-
import org.springframework.context.annotation.Bean;
4-
import org.springframework.context.annotation.Configuration;
5-
63
import com.baeldung.dependency.ArbitraryDependency;
74
import com.baeldung.dependency.YetAnotherArbitraryDependency;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
87

98
@Configuration
109
public class ApplicationContextTestInjectName {
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
package com.baeldung.configuration;
22

3-
import org.springframework.context.annotation.Bean;
4-
import org.springframework.context.annotation.Configuration;
5-
63
import com.baeldung.dependency.AnotherArbitraryDependency;
74
import com.baeldung.dependency.ArbitraryDependency;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
87

98
@Configuration
109
public class ApplicationContextTestInjectQualifier {
1110

12-
@Bean
13-
public ArbitraryDependency defaultFile() {
14-
ArbitraryDependency defaultFile = new ArbitraryDependency();
15-
return defaultFile;
16-
}
11+
@Bean
12+
public ArbitraryDependency defaultFile() {
13+
ArbitraryDependency defaultFile = new ArbitraryDependency();
14+
return defaultFile;
15+
}
1716

18-
@Bean
19-
public ArbitraryDependency namedFile() {
20-
ArbitraryDependency namedFile = new AnotherArbitraryDependency();
21-
return namedFile;
22-
}
17+
@Bean
18+
public ArbitraryDependency namedFile() {
19+
ArbitraryDependency namedFile = new AnotherArbitraryDependency();
20+
return namedFile;
21+
}
2322
}

0 commit comments

Comments
 (0)