Use foreach where possible
This commit is contained in:
parent
7dc28ff376
commit
43737a56bd
|
@ -129,8 +129,8 @@ public class SimpleRoles2GrantedAuthoritiesMapperTests {
|
|||
List<GrantedAuthority> result = mapper
|
||||
.getGrantedAuthorities(Arrays.asList(roles));
|
||||
Collection<String> resultColl = new ArrayList<>(result.size());
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
resultColl.add(result.get(i).getAuthority());
|
||||
for (GrantedAuthority grantedAuthority : result) {
|
||||
resultColl.add(grantedAuthority.getAuthority());
|
||||
}
|
||||
Collection<String> expectedColl = Arrays.asList(expectedGas);
|
||||
assertThat(expectedColl.containsAll(resultColl)
|
||||
|
|
|
@ -180,8 +180,8 @@ public class SessionRegistryImplTests {
|
|||
private boolean contains(String sessionId, Object principal) {
|
||||
List<SessionInformation> info = sessionRegistry.getAllSessions(principal, false);
|
||||
|
||||
for (int i = 0; i < info.size(); i++) {
|
||||
if (sessionId.equals(info.get(i).getSessionId())) {
|
||||
for (SessionInformation sessionInformation : info) {
|
||||
if (sessionId.equals(sessionInformation.getSessionId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,11 +34,11 @@ public final class Hex {
|
|||
char[] result = new char[2 * nBytes];
|
||||
|
||||
int j = 0;
|
||||
for (int i = 0; i < nBytes; i++) {
|
||||
for (byte aByte : bytes) {
|
||||
// Char for top 4 bits
|
||||
result[j++] = HEX[(0xF0 & bytes[i]) >>> 4];
|
||||
result[j++] = HEX[(0xF0 & aByte) >>> 4];
|
||||
// Bottom 4
|
||||
result[j++] = HEX[(0x0F & bytes[i])];
|
||||
result[j++] = HEX[(0x0F & aByte)];
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -122,10 +122,10 @@ public class BCryptTests {
|
|||
@Test
|
||||
public void testHashpw() {
|
||||
print("BCrypt.hashpw(): ");
|
||||
for (int i = 0; i < test_vectors.length; i++) {
|
||||
String plain = test_vectors[i][0];
|
||||
String salt = test_vectors[i][1];
|
||||
String expected = test_vectors[i][2];
|
||||
for (String[] test_vector : test_vectors) {
|
||||
String plain = test_vector[0];
|
||||
String salt = test_vector[1];
|
||||
String expected = test_vector[2];
|
||||
String hashed = BCrypt.hashpw(plain, salt);
|
||||
assertThat(expected).isEqualTo(hashed);
|
||||
print(".");
|
||||
|
@ -176,9 +176,9 @@ public class BCryptTests {
|
|||
@Test
|
||||
public void testCheckpw_success() {
|
||||
print("BCrypt.checkpw w/ good passwords: ");
|
||||
for (int i = 0; i < test_vectors.length; i++) {
|
||||
String plain = test_vectors[i][0];
|
||||
String expected = test_vectors[i][2];
|
||||
for (String[] test_vector : test_vectors) {
|
||||
String plain = test_vector[0];
|
||||
String expected = test_vector[2];
|
||||
assertThat(BCrypt.checkpw(plain, expected)).isTrue();
|
||||
print(".");
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package sample.dms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
@ -88,8 +87,7 @@ public abstract class AbstractElement {
|
|||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String lastCharacter = null;
|
||||
for (Iterator<String> i = strings.iterator(); i.hasNext();) {
|
||||
String token = i.next();
|
||||
for (String token : strings) {
|
||||
if (!"/".equals(lastCharacter) && lastCharacter != null) {
|
||||
sb.append("/");
|
||||
}
|
||||
|
|
|
@ -105,12 +105,12 @@ public class DmsIntegrationTests extends AbstractTransactionalJUnit4SpringContex
|
|||
assertThat(rootElements).hasSize(3);
|
||||
Directory homeDir = null;
|
||||
Directory nonHomeDir = null;
|
||||
for (int i = 0; i < rootElements.length; i++) {
|
||||
if (rootElements[i].getName().equals(username)) {
|
||||
homeDir = (Directory) rootElements[i];
|
||||
for (AbstractElement rootElement : rootElements) {
|
||||
if (rootElement.getName().equals(username)) {
|
||||
homeDir = (Directory) rootElement;
|
||||
}
|
||||
else {
|
||||
nonHomeDir = (Directory) rootElements[i];
|
||||
nonHomeDir = (Directory) rootElement;
|
||||
}
|
||||
}
|
||||
System.out.println("Home directory......: " + homeDir.getFullName());
|
||||
|
@ -135,9 +135,9 @@ public class DmsIntegrationTests extends AbstractTransactionalJUnit4SpringContex
|
|||
// Of course, we shouldn't find a "confidential" directory in the results if we're
|
||||
// filtering
|
||||
Directory nonHomeConfidentialDir = null;
|
||||
for (int i = 0; i < nonHomeElements.length; i++) {
|
||||
if (nonHomeElements[i].getName().equals("confidential")) {
|
||||
nonHomeConfidentialDir = (Directory) nonHomeElements[i];
|
||||
for (AbstractElement nonHomeElement : nonHomeElements) {
|
||||
if (nonHomeElement.getName().equals("confidential")) {
|
||||
nonHomeConfidentialDir = (Directory) nonHomeElement;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -128,8 +128,8 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSourceTests {
|
|||
|
||||
Collection<String> expectedRolesColl = Arrays.asList(expectedRoles);
|
||||
Collection<String> gasRolesSet = new HashSet<>();
|
||||
for (int i = 0; i < gas.size(); i++) {
|
||||
gasRolesSet.add(gas.get(i).getAuthority());
|
||||
for (GrantedAuthority grantedAuthority : gas) {
|
||||
gasRolesSet.add(grantedAuthority.getAuthority());
|
||||
}
|
||||
assertThat(expectedRolesColl.containsAll(gasRolesSet)
|
||||
&& gasRolesSet.containsAll(expectedRolesColl)).withFailMessage(
|
||||
|
|
Loading…
Reference in New Issue