Fixed checkstyle errors causing build failures.
This commit is contained in:
parent
57e45a329f
commit
6921b0dce0
@ -74,6 +74,7 @@ public class RemoteService implements RemoteServiceInterface {
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.error("Thread sleep state interrupted", e);
|
||||
}
|
||||
return waitTime <= THRESHOLD ? value * 10 : RemoteServiceStatus.FAILURE.getRemoteServiceStatusValue();
|
||||
return waitTime <= THRESHOLD ? value * 10
|
||||
: RemoteServiceStatus.FAILURE.getRemoteServiceStatusValue();
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,35 @@
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.ambassador;
|
||||
|
||||
/**
|
||||
* Holds information regarding the status of the Remote Service.
|
||||
*
|
||||
* !Attention - This Enum replaces the integer value previously stored in {@link RemoteServiceInterface}
|
||||
* as SonarCloud was identifying it as an issue. All test cases have been checked after changes, without failures.
|
||||
* <p> This Enum replaces the integer value previously
|
||||
* stored in {@link RemoteServiceInterface} as SonarCloud was identifying
|
||||
* it as an issue. All test cases have been checked after changes,
|
||||
* without failures. </p>
|
||||
*/
|
||||
|
||||
public enum RemoteServiceStatus {
|
||||
|
@ -36,10 +36,10 @@ import com.iluwatar.commander.queue.QueueDatabase;
|
||||
import com.iluwatar.commander.queue.QueueTask;
|
||||
import com.iluwatar.commander.queue.QueueTask.TaskType;
|
||||
import com.iluwatar.commander.shippingservice.ShippingService;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>Commander pattern is used to handle all issues that can come up while making a
|
||||
@ -171,23 +171,6 @@ public class Commander {
|
||||
var list = paymentService.exceptionsList;
|
||||
var t = new Thread(() -> {
|
||||
Retry.Operation op = (l) -> {
|
||||
handlePaymentRetryOperation(order, l);
|
||||
};
|
||||
Retry.HandleErrorIssue<Order> handleError = (o, err) -> {
|
||||
handlePaymentErrorIssue(order, o, err);
|
||||
};
|
||||
var r = new Retry<>(op, handleError, numOfRetries, retryDuration,
|
||||
e -> DatabaseUnavailableException.class.isAssignableFrom(e.getClass()));
|
||||
try {
|
||||
r.perform(list, order);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
||||
private void handlePaymentRetryOperation(Order order, List<Exception> l) throws Exception {
|
||||
if (!l.isEmpty()) {
|
||||
if (DatabaseUnavailableException.class.isAssignableFrom(l.get(0).getClass())) {
|
||||
LOG.debug("Order " + order.id + ": Error in connecting to payment service,"
|
||||
@ -201,16 +184,14 @@ public class Commander {
|
||||
var transactionId = paymentService.receiveRequest(order.price);
|
||||
order.paid = PaymentStatus.DONE;
|
||||
LOG.info("Order " + order.id + ": Payment successful, transaction Id: " + transactionId);
|
||||
|
||||
if (!finalSiteMsgShown) {
|
||||
LOG.info("Payment made successfully, thank you for shopping with us!!");
|
||||
finalSiteMsgShown = true;
|
||||
}
|
||||
sendSuccessMessage(order);
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePaymentErrorIssue(Order order, Order o, Exception err) {
|
||||
};
|
||||
Retry.HandleErrorIssue<Order> handleError = (o, err) -> {
|
||||
if (PaymentDetailsErrorException.class.isAssignableFrom(err.getClass())) {
|
||||
if (!finalSiteMsgShown) {
|
||||
LOG.info("There was an error in payment. Your account/card details "
|
||||
@ -237,6 +218,16 @@ public class Commander {
|
||||
updateQueue(qt);
|
||||
}
|
||||
}
|
||||
};
|
||||
var r = new Retry<>(op, handleError, numOfRetries, retryDuration,
|
||||
e -> DatabaseUnavailableException.class.isAssignableFrom(e.getClass()));
|
||||
try {
|
||||
r.perform(list, order);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
||||
private void updateQueue(QueueTask qt) {
|
||||
@ -483,7 +474,8 @@ public class Commander {
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePaymentPossibleErrorMsgRetryOperation(Order order, List<Exception> l) throws Exception {
|
||||
private void handlePaymentPossibleErrorMsgRetryOperation(Order order, List<Exception> l)
|
||||
throws Exception {
|
||||
if (!l.isEmpty()) {
|
||||
if (DatabaseUnavailableException.class.isAssignableFrom(l.get(0).getClass())) {
|
||||
LOG.debug("Order " + order.id + ": Error in connecting to messaging service "
|
||||
|
@ -40,7 +40,7 @@ public class AiComponentManager {
|
||||
|
||||
private final int numEntities;
|
||||
|
||||
private final Component[] AI_COMPONENTS = new AiComponent[MAX_ENTITIES];
|
||||
private final Component[] aiComponents = new AiComponent[MAX_ENTITIES];
|
||||
|
||||
public AiComponentManager(int numEntities) {
|
||||
this.numEntities = numEntities;
|
||||
@ -51,7 +51,7 @@ public class AiComponentManager {
|
||||
*/
|
||||
public void start() {
|
||||
LOGGER.info("Start AI Game Component");
|
||||
IntStream.range(0, numEntities).forEach(i -> AI_COMPONENTS[i] = new AiComponent());
|
||||
IntStream.range(0, numEntities).forEach(i -> aiComponents[i] = new AiComponent());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,7 +60,7 @@ public class AiComponentManager {
|
||||
public void update() {
|
||||
LOGGER.info("Update AI Game Component");
|
||||
IntStream.range(0, numEntities)
|
||||
.filter(i -> AI_COMPONENTS.length > i && AI_COMPONENTS[i] != null)
|
||||
.forEach(i -> AI_COMPONENTS[i].update());
|
||||
.filter(i -> aiComponents.length > i && aiComponents[i] != null)
|
||||
.forEach(i -> aiComponents[i].update());
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class PhysicsComponentManager {
|
||||
|
||||
private final int numEntities;
|
||||
|
||||
private final Component[] PHYSICS_COMPONENTS = new PhysicsComponent[MAX_ENTITIES];
|
||||
private final Component[] physicsComponents = new PhysicsComponent[MAX_ENTITIES];
|
||||
|
||||
public PhysicsComponentManager(int numEntities) {
|
||||
this.numEntities = numEntities;
|
||||
@ -51,7 +51,7 @@ public class PhysicsComponentManager {
|
||||
*/
|
||||
public void start() {
|
||||
LOGGER.info("Start Physics Game Component ");
|
||||
IntStream.range(0, numEntities).forEach(i -> PHYSICS_COMPONENTS[i] = new PhysicsComponent());
|
||||
IntStream.range(0, numEntities).forEach(i -> physicsComponents[i] = new PhysicsComponent());
|
||||
}
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ public class PhysicsComponentManager {
|
||||
LOGGER.info("Update Physics Game Component ");
|
||||
// Process physics.
|
||||
IntStream.range(0, numEntities)
|
||||
.filter(i -> PHYSICS_COMPONENTS.length > i && PHYSICS_COMPONENTS[i] != null)
|
||||
.forEach(i -> PHYSICS_COMPONENTS[i].update());
|
||||
.filter(i -> physicsComponents.length > i && physicsComponents[i] != null)
|
||||
.forEach(i -> physicsComponents[i].update());
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class RenderComponentManager {
|
||||
|
||||
private final int numEntities;
|
||||
|
||||
private final Component[] RENDER_COMPONENTS = new RenderComponent[MAX_ENTITIES];
|
||||
private final Component[] renderComponents = new RenderComponent[MAX_ENTITIES];
|
||||
|
||||
public RenderComponentManager(int numEntities) {
|
||||
this.numEntities = numEntities;
|
||||
@ -51,7 +51,7 @@ public class RenderComponentManager {
|
||||
*/
|
||||
public void start() {
|
||||
LOGGER.info("Start Render Game Component ");
|
||||
IntStream.range(0, numEntities).forEach(i -> RENDER_COMPONENTS[i] = new RenderComponent());
|
||||
IntStream.range(0, numEntities).forEach(i -> renderComponents[i] = new RenderComponent());
|
||||
}
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ public class RenderComponentManager {
|
||||
LOGGER.info("Update Render Game Component ");
|
||||
// Process Render.
|
||||
IntStream.range(0, numEntities)
|
||||
.filter(i -> RENDER_COMPONENTS.length > i && RENDER_COMPONENTS[i] != null)
|
||||
.forEach(i -> RENDER_COMPONENTS[i].render());
|
||||
.filter(i -> renderComponents.length > i && renderComponents[i] != null)
|
||||
.forEach(i -> renderComponents[i].render());
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.0.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -35,6 +35,7 @@ public class App {
|
||||
*
|
||||
* @param args no argument sent
|
||||
*/
|
||||
|
||||
public static void main(String[] args) {
|
||||
var ram = new Student(1, "Ram", "Street 9, Cupertino");
|
||||
var shyam = new Student(2, "Shyam", "Z bridge, Pune");
|
||||
|
@ -1,10 +1,32 @@
|
||||
/*
|
||||
* The MIT License
|
||||
* Copyright © 2014-2019 Ilkka Seppälä
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.iluwatar.unitofwork;
|
||||
|
||||
public enum UnitActions {
|
||||
INSERT("INSERT"),
|
||||
DELETE("DELETE"),
|
||||
MODIFY("MODIFY")
|
||||
;
|
||||
MODIFY("MODIFY");
|
||||
|
||||
private final String actionValue;
|
||||
|
||||
|
@ -31,6 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
* AppTest
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
public void shouldExecuteWithoutException() {
|
||||
assertDoesNotThrow(() -> App.main(new String[]{}));
|
||||
|
Loading…
x
Reference in New Issue
Block a user