Skip to content

Commit 53ee0fe

Browse files
committed
Polishing.
Original pull request: #620. See #583.
1 parent ce39a53 commit 53ee0fe

File tree

5 files changed

+40
-31
lines changed

5 files changed

+40
-31
lines changed

rest/projections/src/test/java/example/springdata/rest/projections/SimpleProjectionTests.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
package example.springdata.rest.projections;
1717

1818
import static org.hamcrest.CoreMatchers.*;
19-
import static org.hamcrest.MatcherAssert.assertThat;
19+
import static org.hamcrest.MatcherAssert.*;
2020

2121
import java.util.HashMap;
2222
import java.util.Map;
2323

2424
import org.junit.jupiter.api.Test;
25+
2526
import org.springframework.beans.factory.annotation.Value;
2627
import org.springframework.data.projection.ProjectionFactory;
2728
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
@@ -30,13 +31,14 @@
3031
* Test cases showing the programatic use of a {@link ProjectionFactory}.
3132
*
3233
* @author Oliver Gierke
34+
* @author Divya Srivastava
3335
*/
34-
public class SimpleProjectionTests {
36+
class SimpleProjectionTests {
3537

36-
ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
38+
private ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
3739

3840
@Test
39-
public void createMapBackedProjection() {
41+
void createMapBackedProjection() {
4042

4143
Customer customer = factory.createProjection(Customer.class);
4244
customer.setFirstname("Dave");
@@ -51,7 +53,7 @@ public void createMapBackedProjection() {
5153
}
5254

5355
@Test
54-
public void createsProxyForSourceMap() {
56+
void createsProxyForSourceMap() {
5557

5658
Map<String, Object> backingMap = new HashMap<>();
5759
backingMap.put("firstname", "Dave");

rest/security/src/test/java/example/springdata/rest/security/MethodLevelSecurityTests.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
*/
1616
package example.springdata.rest.security;
1717

18-
import static org.junit.jupiter.api.Assertions.fail;
18+
import static org.junit.jupiter.api.Assertions.*;
1919

2020
import org.junit.jupiter.api.BeforeEach;
2121
import org.junit.jupiter.api.Test;
22+
2223
import org.springframework.beans.factory.annotation.Autowired;
2324
import org.springframework.boot.test.context.SpringBootTest;
2425
import org.springframework.security.access.AccessDeniedException;
@@ -30,19 +31,20 @@
3031
*
3132
* @author Greg Turnquist
3233
* @author Oliver Gierke
34+
* @author Divya Srivastava
3335
*/
3436
@SpringBootTest
35-
public class MethodLevelSecurityTests {
37+
class MethodLevelSecurityTests {
3638

3739
@Autowired ItemRepository itemRepository;
3840

3941
@BeforeEach
40-
public void setUp() {
42+
void setUp() {
4143
SecurityContextHolder.clearContext();
4244
}
4345

4446
@Test
45-
public void rejectsMethodInvocationsForNoAuth() {
47+
void rejectsMethodInvocationsForNoAuth() {
4648

4749
try {
4850
itemRepository.findAll();
@@ -67,7 +69,7 @@ public void rejectsMethodInvocationsForNoAuth() {
6769
}
6870

6971
@Test
70-
public void rejectsMethodInvocationsForAuthWithInsufficientPermissions() {
72+
void rejectsMethodInvocationsForAuthWithInsufficientPermissions() {
7173

7274
SecurityUtils.runAs("system", "system", "ROLE_USER");
7375

@@ -88,7 +90,7 @@ public void rejectsMethodInvocationsForAuthWithInsufficientPermissions() {
8890
}
8991

9092
@Test
91-
public void allowsMethodInvocationsForAuthWithSufficientPermissions() {
93+
void allowsMethodInvocationsForAuthWithSufficientPermissions() {
9294

9395
SecurityUtils.runAs("system", "system", "ROLE_USER", "ROLE_ADMIN");
9496

rest/security/src/test/java/example/springdata/rest/security/UrlLevelSecurityTests.java

+12-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package example.springdata.rest.security;
1717

1818
import static org.hamcrest.CoreMatchers.*;
19-
import static org.hamcrest.MatcherAssert.assertThat;
19+
import static org.hamcrest.MatcherAssert.*;
2020
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
2121
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
2222
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
@@ -25,6 +25,7 @@
2525

2626
import org.junit.jupiter.api.BeforeEach;
2727
import org.junit.jupiter.api.Test;
28+
2829
import org.springframework.beans.factory.annotation.Autowired;
2930
import org.springframework.boot.test.context.SpringBootTest;
3031
import org.springframework.hateoas.MediaTypes;
@@ -42,27 +43,29 @@
4243
*
4344
* @author Greg Turnquist
4445
* @author Oliver Gierke
46+
* @author Divya Srivastava
4547
*/
4648
@SpringBootTest
47-
public class UrlLevelSecurityTests {
49+
class UrlLevelSecurityTests {
4850

49-
static final String PAYLOAD = "{\"firstName\": \"Saruman\", \"lastName\": \"the White\", " + "\"title\": \"Wizard\"}";
51+
private static final String PAYLOAD = "{\"firstName\": \"Saruman\", \"lastName\": \"the White\", "
52+
+ "\"title\": \"Wizard\"}";
5053

5154
@Autowired WebApplicationContext context;
5255
@Autowired FilterChainProxy filterChain;
5356

54-
MockMvc mvc;
57+
private MockMvc mvc;
5558

5659
@BeforeEach
57-
public void setUp() {
60+
void setUp() {
5861

5962
this.mvc = webAppContextSetup(context).addFilters(filterChain).build();
6063

6164
SecurityContextHolder.clearContext();
6265
}
6366

6467
@Test
65-
public void allowsAccessToRootResource() throws Exception {
68+
void allowsAccessToRootResource() throws Exception {
6669

6770
mvc.perform(get("/").//
6871
accept(MediaTypes.HAL_JSON)).//
@@ -71,7 +74,7 @@ public void allowsAccessToRootResource() throws Exception {
7174
}
7275

7376
@Test
74-
public void rejectsPostAccessToCollectionResource() throws Exception {
77+
void rejectsPostAccessToCollectionResource() throws Exception {
7578

7679
mvc.perform(post("/employees").//
7780
content(PAYLOAD).//
@@ -80,7 +83,7 @@ public void rejectsPostAccessToCollectionResource() throws Exception {
8083
}
8184

8285
@Test
83-
public void allowsGetRequestsButRejectsPostForUser() throws Exception {
86+
void allowsGetRequestsButRejectsPostForUser() throws Exception {
8487

8588
HttpHeaders headers = new HttpHeaders();
8689
headers.add(HttpHeaders.ACCEPT, MediaTypes.HAL_JSON_VALUE);
@@ -98,7 +101,7 @@ public void allowsGetRequestsButRejectsPostForUser() throws Exception {
98101
}
99102

100103
@Test
101-
public void allowsPostRequestForAdmin() throws Exception {
104+
void allowsPostRequestForAdmin() throws Exception {
102105

103106
HttpHeaders headers = new HttpHeaders();
104107
headers.set(HttpHeaders.ACCEPT, MediaTypes.HAL_JSON_VALUE);

rest/starbucks/src/test/java/example/springdata/rest/stores/StarbucksClient.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@
5151
* A test case to discover the search resource and execute a predefined search with it.
5252
*
5353
* @author Oliver Gierke
54+
* @author Divya Srivastava
5455
*/
5556
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
5657
@Slf4j
57-
public class StarbucksClient {
58+
class StarbucksClient {
5859

5960
@SpringBootApplication
6061
static class Config {
@@ -70,7 +71,7 @@ public RestTemplate restTemplate() {
7071
private static final String SERVICE_URI = "http://localhost:%s/api";
7172

7273
@Test
73-
public void discoverStoreSearch() {
74+
void discoverStoreSearch() {
7475

7576
Traverson traverson = new Traverson(URI.create(String.format(SERVICE_URI, port)), MediaTypes.HAL_JSON);
7677

@@ -103,7 +104,7 @@ public void discoverStoreSearch() {
103104
@Autowired RestOperations restOperations;
104105

105106
@Test
106-
public void accessServiceUsingRestTemplate() {
107+
void accessServiceUsingRestTemplate() {
107108

108109
// Access root resource
109110

@@ -125,20 +126,20 @@ public void accessServiceUsingRestTemplate() {
125126
static class Store {
126127

127128
public String name;
128-
public Address address;
129+
Address address;
129130

130131
static class Address {
131132

132-
public String city, zip, street;
133-
public Location location;
133+
String city, zip, street;
134+
Location location;
134135

135136
@Override
136137
public String toString() {
137138
return String.format("%s, %s %s - lat: %s, long: %s", street, zip, city, location.y, location.x);
138139
}
139140

140141
static class Location {
141-
public double x, y;
142+
double x, y;
142143
}
143144
}
144145
}

rest/uri-customization/src/test/java/example/springdata/rest/uris/WebIntegrationTests.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,23 @@
3131
* Integration tests to make sure the URI customizations are applied.
3232
*
3333
* @author Oliver Gierke
34+
* @author Divya Srivastava
3435
* @soundtrack Clueso - Gewinner (Stadtrandlichter Live)
3536
*/
3637
@SpringBootTest
37-
public class WebIntegrationTests {
38+
class WebIntegrationTests {
3839

3940
@Autowired WebApplicationContext context;
4041

41-
MockMvc mvc;
42+
private MockMvc mvc;
4243

4344
@BeforeEach
44-
public void setUp() {
45+
void setUp() {
4546
this.mvc = MockMvcBuilders.webAppContextSetup(context).build();
4647
}
4748

4849
@Test
49-
public void identifiesResourcesUsingUsername() throws Exception {
50+
void identifiesResourcesUsingUsername() throws Exception {
5051

5152
mvc.perform(get("/users/olivergierke")).//
5253
andExpect(status().isOk()).//

0 commit comments

Comments
 (0)