fix sonar issues (#6394)

This commit is contained in:
João Felipe Pizzolotto Bini 2019-03-27 13:35:58 -03:00 committed by maibin
parent 07b62fd912
commit e506bc1d75
10 changed files with 14 additions and 33 deletions

View File

@ -64,11 +64,11 @@ public class ForkJoinStateMachineConfiguration extends StateMachineConfigurerAda
@Bean
public Guard<String, String> mediumGuard() {
return (ctx) -> false;
return ctx -> false;
}
@Bean
public Guard<String, String> highGuard() {
return (ctx) -> false;
return ctx -> false;
}
}

View File

@ -50,11 +50,11 @@ public class JunctionStateMachineConfiguration extends StateMachineConfigurerAda
@Bean
public Guard<String, String> mediumGuard() {
return (ctx) -> false;
return ctx -> false;
}
@Bean
public Guard<String, String> highGuard() {
return (ctx) -> false;
return ctx -> false;
}
}

View File

@ -18,7 +18,7 @@ import java.util.logging.Logger;
@EnableStateMachine
public class SimpleStateMachineConfiguration extends StateMachineConfigurerAdapter<String, String> {
public static final Logger LOGGER = Logger.getLogger(SimpleStateMachineConfiguration.class.getName());
private static final Logger LOGGER = Logger.getLogger(SimpleStateMachineConfiguration.class.getName());
@Override
public void configure(StateMachineConfigurationConfigurer<String, String> config) throws Exception {
@ -80,7 +80,7 @@ public class SimpleStateMachineConfiguration extends StateMachineConfigurerAdapt
@Bean
public Guard<String, String> simpleGuard() {
return (ctx) -> {
return ctx -> {
int approvalCount = (int) ctx
.getExtendedState()
.getVariables()

View File

@ -7,10 +7,10 @@ import java.util.logging.Logger;
public class StateMachineListener extends StateMachineListenerAdapter {
public static final Logger LOGGER = Logger.getLogger(StateMachineListener.class.getName());
private static final Logger LOGGER = Logger.getLogger(StateMachineListener.class.getName());
@Override
public void stateChanged(State from, State to) {
LOGGER.info(String.format("Transitioned from %s to %s%n", from == null ? "none" : from.getId(), to.getId()));
LOGGER.info(() -> String.format("Transitioned from %s to %s%n", from == null ? "none" : from.getId(), to.getId()));
}
}

View File

@ -1,18 +1,15 @@
package com.baeldung.spring.statemachine;
import com.baeldung.spring.statemachine.config.ForkJoinStateMachineConfiguration;
import com.baeldung.spring.statemachine.config.JunctionStateMachineConfiguration;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.statemachine.StateMachine;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import java.util.Arrays;
import static org.junit.Assert.assertEquals;

View File

@ -1,18 +1,15 @@
package com.baeldung.spring.statemachine;
import com.baeldung.spring.statemachine.config.HierarchicalStateMachineConfiguration;
import com.baeldung.spring.statemachine.config.JunctionStateMachineConfiguration;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.statemachine.StateMachine;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import java.util.Arrays;
import static org.junit.Assert.assertEquals;

View File

@ -1,20 +1,16 @@
package com.baeldung.spring.statemachine;
import com.baeldung.spring.statemachine.config.JunctionStateMachineConfiguration;
import com.baeldung.spring.statemachine.config.SimpleEnumStateMachineConfiguration;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.statemachine.StateMachine;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = JunctionStateMachineConfiguration.class)
public class JunctionStateMachineIntegrationTest {

View File

@ -3,19 +3,15 @@ package com.baeldung.spring.statemachine;
import com.baeldung.spring.statemachine.applicationreview.ApplicationReviewEvents;
import com.baeldung.spring.statemachine.applicationreview.ApplicationReviewStates;
import com.baeldung.spring.statemachine.config.SimpleEnumStateMachineConfiguration;
import com.baeldung.spring.statemachine.config.SimpleStateMachineConfiguration;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.statemachine.StateMachine;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

View File

@ -1,11 +1,11 @@
package com.baeldung.spring.statemachine;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import static org.junit.Assert.assertEquals;
public class StateMachineBuilderIntegrationTest {
@Test

View File

@ -1,22 +1,17 @@
package com.baeldung.spring.statemachine;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.baeldung.spring.statemachine.config.SimpleStateMachineConfiguration;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.statemachine.StateMachine;
import com.baeldung.spring.statemachine.config.SimpleStateMachineConfiguration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SimpleStateMachineConfiguration.class)
@ -42,7 +37,7 @@ public class StateMachineIntegrationTest {
}
@Test
public void whenSimpleStringMachineActionState_thenActionExecuted() throws InterruptedException {
public void whenSimpleStringMachineActionState_thenActionExecuted() {
stateMachine.sendEvent("E3");
assertEquals("S3", stateMachine.getState().getId());