Upgrading Spotbugs to 4.4.1
This commit is contained in:
committed by
Petri Tuomola
parent
60a4d71dd0
commit
81e5c4d814
+4
-1
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.fineract.integrationtests;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.restassured.builder.RequestSpecBuilder;
|
||||
import io.restassured.builder.ResponseSpecBuilder;
|
||||
import io.restassured.http.ContentType;
|
||||
@@ -45,6 +46,7 @@ public class AuditIntegrationTest {
|
||||
private RequestSpecification requestSpec;
|
||||
private ClientHelper clientHelper;
|
||||
private AuditHelper auditHelper;
|
||||
private static final Random rand = new Random();
|
||||
|
||||
/**
|
||||
* Sets up the essential settings for the TEST like contentType, expectedStatusCode. It uses the '@BeforeEach'
|
||||
@@ -105,6 +107,8 @@ public class AuditIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressFBWarnings(value = {
|
||||
"DMI_RANDOM_USED_ONLY_ONCE" }, justification = "False positive for random object created and used only once")
|
||||
public void checkAuditsWithLimitParam() {
|
||||
// Create client
|
||||
final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
@@ -117,7 +121,6 @@ public class AuditIntegrationTest {
|
||||
this.clientHelper.reactivateClient(clientId);
|
||||
}
|
||||
|
||||
Random rand = new Random();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
// limit contains a number between 1-8
|
||||
int limit = rand.nextInt(7) + 1;
|
||||
|
||||
+4
-1
@@ -20,6 +20,7 @@ package org.apache.fineract.integrationtests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.restassured.builder.RequestSpecBuilder;
|
||||
import io.restassured.builder.ResponseSpecBuilder;
|
||||
import io.restassured.http.ContentType;
|
||||
@@ -38,6 +39,7 @@ public class ClientTest {
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private ClientHelper clientHelper;
|
||||
private static final Random rand = new Random();
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
@@ -149,9 +151,10 @@ public class ClientTest {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
@SuppressFBWarnings(value = {
|
||||
"DMI_RANDOM_USED_ONLY_ONCE" }, justification = "False positive for random object created and used only once")
|
||||
public void testPendingOnlyClientRequest() {
|
||||
|
||||
Random rand = new Random();
|
||||
// Add a few clients to the server and activate a random amount of them
|
||||
for (int i = 0; i < 15; i++) {
|
||||
final Integer clientId = ClientHelper.createClientAsEntity(this.requestSpec, this.responseSpec);
|
||||
|
||||
+3
@@ -31,6 +31,7 @@ import com.google.common.truth.StringSubject;
|
||||
import com.google.common.truth.Subject;
|
||||
import com.google.common.truth.Truth;
|
||||
import com.google.common.truth.Truth8;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
@@ -76,6 +77,8 @@ public abstract class IntegrationTest {
|
||||
return FineractClient.DATE_FORMAT;
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = {
|
||||
"DMI_RANDOM_USED_ONLY_ONCE" }, justification = "False positive for random object created and used only once")
|
||||
protected String random() {
|
||||
return Long.toString(random.nextLong());
|
||||
}
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ public class SchedulerJobHelper {
|
||||
* @author Michael Vorburger.ch
|
||||
*/
|
||||
public void executeAndAwaitJob(String jobName) {
|
||||
final Duration timeout = Duration.ofSeconds(180);
|
||||
final Duration timeout = Duration.ofMinutes(3);
|
||||
final Duration pause = Duration.ofSeconds(1);
|
||||
DateTimeFormatter df = DateTimeFormatter.ISO_INSTANT; // FINERACT-926
|
||||
Instant beforeExecuteTime = now().truncatedTo(ChronoUnit.SECONDS);
|
||||
|
||||
+8
-3
@@ -23,6 +23,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.restassured.RestAssured;
|
||||
import io.restassured.http.ContentType;
|
||||
import io.restassured.path.json.JsonPath;
|
||||
@@ -57,6 +58,7 @@ public final class Utils {
|
||||
}
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Utils.class);
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static final String TENANT_PARAM_NAME = "tenantIdentifier";
|
||||
public static final String DEFAULT_TENANT = "default";
|
||||
@@ -196,12 +198,13 @@ public final class Utils {
|
||||
return reformattedStr;
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = {
|
||||
"DMI_RANDOM_USED_ONLY_ONCE" }, justification = "False positive for random object created and used only once")
|
||||
public static String randomStringGenerator(final String prefix, final int len, final String sourceSetString) {
|
||||
final int lengthOfSource = sourceSetString.length();
|
||||
final Random rnd = new Random();
|
||||
final StringBuilder sb = new StringBuilder(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
sb.append(sourceSetString.charAt(rnd.nextInt(lengthOfSource)));
|
||||
sb.append(sourceSetString.charAt(random.nextInt(lengthOfSource)));
|
||||
}
|
||||
return prefix + sb.toString();
|
||||
}
|
||||
@@ -214,10 +217,12 @@ public final class Utils {
|
||||
return randomStringGenerator(prefix, lenOfRandomSuffix);
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = {
|
||||
"DMI_RANDOM_USED_ONLY_ONCE" }, justification = "False positive for random object created and used only once")
|
||||
public static Long randomNumberGenerator(final int expectedLength) {
|
||||
final String source = "1234567890";
|
||||
final int lengthofSource = source.length();
|
||||
final Random random = new Random();
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder(expectedLength);
|
||||
for (int i = 0; i < expectedLength; i++) {
|
||||
stringBuilder.append(source.charAt(random.nextInt(lengthofSource)));
|
||||
|
||||
+8
-2
@@ -19,6 +19,7 @@
|
||||
package org.apache.fineract.integrationtests.common;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import io.restassured.specification.ResponseSpecification;
|
||||
import java.util.HashMap;
|
||||
@@ -34,6 +35,7 @@ public final class WorkingDaysHelper {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WorkingDaysHelper.class);
|
||||
private static final String WORKINGDAYS_URL = "/fineract-provider/api/v1/workingdays";
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static Object updateWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
@@ -49,21 +51,25 @@ public final class WorkingDaysHelper {
|
||||
jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = {
|
||||
"DMI_RANDOM_USED_ONLY_ONCE" }, justification = "False positive for random object created and used only once")
|
||||
public static String updateWorkingDaysAsJson() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("recurrence", "FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU");
|
||||
map.put("locale", "en");
|
||||
map.put("repaymentRescheduleType", new Random().nextInt(4) + 1);
|
||||
map.put("repaymentRescheduleType", random.nextInt(4) + 1);
|
||||
map.put("extendTermForDailyRepayments", false);
|
||||
LOG.info("map : {}", map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = {
|
||||
"DMI_RANDOM_USED_ONLY_ONCE" }, justification = "False positive for random object created and used only once")
|
||||
public static String updateWorkingDayWithWrongRecur() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("recurrence", "FREQ=WEEKLY;INTERVAL=1;BYDAY=MP,TI,TE,TH");
|
||||
map.put("locale", "en");
|
||||
map.put("repaymentRescheduleType", new Random().nextInt(4) + 1);
|
||||
map.put("repaymentRescheduleType", random.nextInt(4) + 1);
|
||||
map.put("extendTermForDailyRepayments", false);
|
||||
LOG.info("map : {}", map);
|
||||
return new Gson().toJson(map);
|
||||
|
||||
+6
-1
@@ -19,6 +19,7 @@
|
||||
package org.apache.fineract.integrationtests.common.provisioning;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -32,10 +33,14 @@ import org.apache.fineract.integrationtests.common.accounting.Account;
|
||||
|
||||
public final class ProvisioningHelper {
|
||||
|
||||
private static final Random rand = new Random();
|
||||
|
||||
private ProvisioningHelper() {
|
||||
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(value = {
|
||||
"DMI_RANDOM_USED_ONLY_ONCE" }, justification = "False positive for random object created and used only once")
|
||||
public static Map createProvisioingCriteriaJson(ArrayList<Integer> loanProducts, ArrayList categories, Account liability,
|
||||
Account expense) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
@@ -44,7 +49,7 @@ public final class ProvisioningHelper {
|
||||
DateFormat simple = new SimpleDateFormat("dd MMMM yyyy");
|
||||
String formattedString = simple
|
||||
.format(Date.from(Utils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
|
||||
Random rand = new Random();
|
||||
|
||||
String criteriaName = "General Provisioning Criteria" + formattedString + rand.nextLong();
|
||||
map.put("criteriaName", criteriaName);
|
||||
map.put("locale", "en");
|
||||
|
||||
Reference in New Issue
Block a user