Fix warnings

This commit is contained in:
Rossen Stoyanchev
2018-02-08 17:46:10 -05:00
parent f107fdcdcf
commit da6d1492c1
29 changed files with 111 additions and 132 deletions

View File

@@ -58,7 +58,7 @@ public class GenericConversionService implements ConversionService {
/**
* Indexes classes by well-known aliases.
*/
private final Map<String, Class<?>> aliasMap = new HashMap<String, Class<?>>();
private final Map<String, Class<?>> aliasMap = new HashMap<>();
/**
* An optional parent conversion service.
@@ -79,7 +79,7 @@ public class GenericConversionService implements ConversionService {
* @param delegateConversionService the conversion service
*/
public GenericConversionService(org.springframework.core.convert.ConversionService delegateConversionService) {
Assert.notNull(delegateConversionService);
Assert.notNull(delegateConversionService, "Missing delegate ConversionService");
this.delegate = delegateConversionService;
}

View File

@@ -93,7 +93,7 @@ public class MessageBuilderTests extends TestCase {
}
public void testBuildCodesNull() {
MessageResolver resolver = builder.codes(null).build();
MessageResolver resolver = builder.codes().build();
try {
resolver.resolveMessage(messageSource, locale);
fail("Should have failed");
@@ -103,7 +103,7 @@ public class MessageBuilderTests extends TestCase {
}
public void testBuildArgsNull() {
MessageResolver resolver = builder.args(null).build();
MessageResolver resolver = builder.args().build();
try {
resolver.resolveMessage(messageSource, locale);
fail("Should have failed");

View File

@@ -31,7 +31,6 @@ import javax.faces.render.ResponseStateManager;
*
* @since 2.4
*/
@SuppressWarnings("deprecation")
public abstract class ResponseStateManagerWrapper extends ResponseStateManager implements
FacesWrapper<ResponseStateManager> {

View File

@@ -18,7 +18,6 @@ package org.springframework.faces.webflow;
import javax.faces.context.FacesContext;
import org.springframework.webflow.execution.FlowExecutionListener;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.RequestContext;
/**
@@ -28,7 +27,7 @@ import org.springframework.webflow.execution.RequestContext;
*
* @author Rossen Stoyanchev
*/
public class FlowFacesContextLifecycleListener extends FlowExecutionListenerAdapter {
public class FlowFacesContextLifecycleListener implements FlowExecutionListener {
public static final String DEFAULT_FACES_CONTEXT =
FlowFacesContextLifecycleListener.class.getName() + ".DEFAULT_FACES_CONTEXT";

View File

@@ -49,7 +49,6 @@ import org.springframework.webflow.execution.RequestContextHolder;
* @see FlowResponseStateManager
* @see FlowRenderKit
*/
@SuppressWarnings("deprecation")
public class MyFacesFlowResponseStateManager extends ResponseStateManager
implements FacesWrapper<ResponseStateManager> {

View File

@@ -32,7 +32,7 @@ public class FlowActionListenerTests extends TestCase {
LocalAttributeMap<Object> flash = new LocalAttributeMap<>();
EasyMock.expect(this.context.getFlashScope()).andStubReturn(flash);
EasyMock.expect(this.context.getCurrentState()).andStubReturn(new MockViewState());
EasyMock.replay(new Object[] { this.context });
EasyMock.replay(this.context);
}
protected void tearDown() throws Exception {

View File

@@ -3,7 +3,6 @@ package org.springframework.faces.webflow;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.faces.FacesException;
import javax.faces.application.ViewHandler;
import javax.faces.component.UIInput;
@@ -23,10 +22,10 @@ import javax.faces.event.SystemEvent;
import javax.faces.lifecycle.Lifecycle;
import junit.framework.TestCase;
import org.apache.el.ExpressionFactoryImpl;
import org.apache.myfaces.test.mock.MockApplication20;
import org.easymock.EasyMock;
import org.apache.el.ExpressionFactoryImpl;
import org.springframework.binding.expression.ExpressionParser;
import org.springframework.binding.expression.support.FluentParserContext;
import org.springframework.mock.web.MockHttpServletRequest;
@@ -60,8 +59,6 @@ public class JsfViewFactoryTests extends TestCase {
private Lifecycle lifecycle;
private PhaseListener trackingListener;
private final ExpressionParser parser = new WebFlowELExpressionParser(new ExpressionFactoryImpl());
private final MockExternalContext extContext = new MockExternalContext();
@@ -94,8 +91,8 @@ public class JsfViewFactoryTests extends TestCase {
this.jsfMock.setUp();
ExceptionEventAwareMockApplication application = new ExceptionEventAwareMockApplication();
((MockBaseFacesContext) FlowFacesContext.getCurrentInstance()).setApplication(application);
this.trackingListener = new TrackingPhaseListener();
this.jsfMock.lifecycle().addPhaseListener(this.trackingListener);
PhaseListener trackingListener = new TrackingPhaseListener();
this.jsfMock.lifecycle().addPhaseListener(trackingListener);
this.jsfMock.facesContext().setViewRoot(null);
this.jsfMock.facesContext().getApplication().setViewHandler(this.viewHandler);
}
@@ -116,7 +113,7 @@ public class JsfViewFactoryTests extends TestCase {
this.context.inViewState();
EasyMock.expectLastCall().andReturn(true);
EasyMock.replay(new Object[] { this.context });
EasyMock.replay(this.context);
View newView = this.factory.getView(this.context);
@@ -147,7 +144,7 @@ public class JsfViewFactoryTests extends TestCase {
this.context.inViewState();
EasyMock.expectLastCall().andReturn(true);
EasyMock.replay(new Object[] { this.context });
EasyMock.replay(this.context);
View restoredView = this.factory.getView(this.context);
@@ -162,6 +159,7 @@ public class JsfViewFactoryTests extends TestCase {
/**
* View already exists in view/flash scope and must be restored and the lifecycle executed, no flow event signaled
*/
@SuppressWarnings("deprecation")
public final void testGetView_RestoreWithBindings() {
this.lifecycle = new NoExecutionLifecycle(this.jsfMock.lifecycle());
@@ -174,8 +172,7 @@ public class JsfViewFactoryTests extends TestCase {
UIPanel panel = new UIPanel();
panel.setId("panel1");
UIOutput output = new UIOutput();
output.setValueBinding("binding", this.jsfMock.facesContext().getApplication()
.createValueBinding("#{myBean.output}"));
output.setValueBinding("binding", this.jsfMock.facesContext().getApplication().createValueBinding("#{myBean.output}"));
output.setId("output1");
UIInput input = new UIInput();
input.setValueBinding("binding", this.jsfMock.facesContext().getApplication().createValueBinding("#{myBean.input}"));
@@ -186,6 +183,7 @@ public class JsfViewFactoryTests extends TestCase {
panel.getChildren().add(input);
TestBean testBean = new TestBean();
//noinspection unchecked
this.jsfMock.externalContext().getRequestMap().put("myBean", testBean);
((MockViewHandler) this.viewHandler).setRestoreView(existingRoot);
@@ -193,7 +191,7 @@ public class JsfViewFactoryTests extends TestCase {
this.context.inViewState();
EasyMock.expectLastCall().andReturn(true);
EasyMock.replay(new Object[] { this.context });
EasyMock.replay(this.context);
View restoredView = this.factory.getView(this.context);
@@ -228,13 +226,13 @@ public class JsfViewFactoryTests extends TestCase {
this.context.inViewState();
EasyMock.expectLastCall().andReturn(true);
EasyMock.replay(new Object[] { this.context });
EasyMock.replay(this.context);
View restoredView = this.factory.getView(this.context);
assertNotNull("A View was not restored", restoredView);
assertTrue("A JsfView was expected", restoredView instanceof JsfView);
assertTrue("An ViewRoot was not set", ((JsfView) restoredView).getViewRoot() instanceof UIViewRoot);
assertTrue("An ViewRoot was not set", ((JsfView) restoredView).getViewRoot() != null);
assertEquals("View name did not match", VIEW_ID, ((JsfView) restoredView).getViewRoot().getViewId());
assertFalse("An unexpected event was signaled,", restoredView.hasFlowEvent());
assertTrue("The PostRestoreViewEvent was not seen", existingRoot.isPostRestoreStateEventSeen());
@@ -254,7 +252,7 @@ public class JsfViewFactoryTests extends TestCase {
this.jsfMock.facesContext().setViewRoot(newRoot);
this.jsfMock.facesContext().renderResponse();
EasyMock.replay(new Object[] { this.context });
EasyMock.replay(this.context);
View newView = this.factory.getView(this.context);
@@ -266,7 +264,7 @@ public class JsfViewFactoryTests extends TestCase {
assertTrue("The PostRestoreViewEvent was not seen", newRoot.isPostRestoreStateEventSeen());
}
public void testGetView_ExceptionsOnPostRestoreStateEvent() throws Exception {
public void testGetView_ExceptionsOnPostRestoreStateEvent() {
this.lifecycle = new NoExecutionLifecycle(this.jsfMock.lifecycle());
this.factory = new JsfViewFactory(this.parser.parseExpression(VIEW_ID,
new FluentParserContext().template().evaluate(RequestContext.class).expectResult(String.class)),
@@ -280,7 +278,7 @@ public class JsfViewFactoryTests extends TestCase {
this.context.inViewState();
EasyMock.expectLastCall().andReturn(true);
EasyMock.replay(new Object[] { this.context });
EasyMock.replay(this.context);
this.factory.getView(this.context);
ExceptionEventAwareMockApplication application = (ExceptionEventAwareMockApplication) FlowFacesContext
.getCurrentInstance().getApplication();

View File

@@ -49,7 +49,7 @@ class FlowBuilderInfo {
Assert.hasText(className, "The fully-qualified FlowBuilder class name is required");
this.className = className;
setId(id);
this.attributes = (attributes != null ? attributes : Collections.<FlowElementAttribute> emptySet());
this.attributes = (attributes != null ? attributes : Collections.emptySet());
}
private void setId(String id) {

View File

@@ -47,7 +47,7 @@ class FlowLocation {
Assert.hasText(path, "The path is required");
this.id = id;
this.path = path;
this.attributes = (attributes != null ? attributes : Collections.<FlowElementAttribute> emptySet());
this.attributes = (attributes != null ? attributes : Collections.emptySet());
}
public String getId() {

View File

@@ -38,8 +38,7 @@ public class CollectionUtils {
/**
* The shared, singleton empty attribute map instance.
*/
public static final AttributeMap<Object> EMPTY_ATTRIBUTE_MAP = new LocalAttributeMap<>(
Collections.<String, Object> emptyMap());
public static final AttributeMap<Object> EMPTY_ATTRIBUTE_MAP = new LocalAttributeMap<>(Collections.emptyMap());
/**
* Private constructor to avoid instantiation.
@@ -78,6 +77,7 @@ public class CollectionUtils {
* @param objects the objects to add
* @return whether or not the target collection changed
*/
@SuppressWarnings("unchecked")
public static <T> boolean addAllNoDuplicates(List<T> target, T... objects) {
if (objects == null || objects.length == 0) {
return false;

View File

@@ -49,7 +49,7 @@ class FlowExecutionListeners {
* Create a flow execution listener helper that wraps an empty listener array.
*/
public FlowExecutionListeners() {
this(null);
this((FlowExecutionListener[]) null);
}
/**

View File

@@ -39,7 +39,7 @@ public class DelegatingFlowViewResolver implements FlowViewResolver {
* @param viewResolvers the Spring MVC view resolver chain to delegate to
*/
public DelegatingFlowViewResolver(List<ViewResolver> viewResolvers) {
this.viewResolvers = viewResolvers != null ? viewResolvers : Collections.<ViewResolver> emptyList();
this.viewResolvers = viewResolvers != null ? viewResolvers : Collections.emptyList();
}
public View resolveView(String viewId, RequestContext context) {

View File

@@ -245,7 +245,8 @@ public class FlowHandlerAdapter extends WebContentGenerator implements HandlerAd
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
FlowHandler flowHandler = (FlowHandler) handler;
checkAndPrepare(request, response, false);
checkRequest(request);
prepareResponse(response);
String flowExecutionKey = flowUrlHandler.getFlowExecutionKey(request);
if (flowExecutionKey != null) {
try {

View File

@@ -35,7 +35,6 @@ import org.springframework.webflow.core.collection.MutableAttributeMap;
import org.springframework.webflow.definition.FlowDefinition;
import org.springframework.webflow.execution.FlowExecutionException;
import org.springframework.webflow.execution.FlowExecutionListener;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.FlowSession;
import org.springframework.webflow.execution.RequestContext;
@@ -78,7 +77,7 @@ import org.springframework.webflow.execution.RequestContext;
* @author Juergen Hoeller
* @author Ben Hale
*/
public class HibernateFlowExecutionListener extends FlowExecutionListenerAdapter {
public class HibernateFlowExecutionListener implements FlowExecutionListener {
private static final boolean hibernate3Present = ClassUtils.isPresent("org.hibernate.connection.ConnectionProvider",
HibernateFlowExecutionListener.class.getClassLoader());

View File

@@ -29,7 +29,6 @@ import org.springframework.webflow.core.collection.MutableAttributeMap;
import org.springframework.webflow.definition.FlowDefinition;
import org.springframework.webflow.execution.FlowExecutionException;
import org.springframework.webflow.execution.FlowExecutionListener;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.FlowSession;
import org.springframework.webflow.execution.RequestContext;
@@ -73,7 +72,7 @@ import org.springframework.webflow.execution.RequestContext;
* @author Keith Donald
* @author Juergen Hoeller
*/
public class JpaFlowExecutionListener extends FlowExecutionListenerAdapter {
public class JpaFlowExecutionListener implements FlowExecutionListener {
/**
* The name of the attribute the flow {@link EntityManager persistence context} is indexed under.

View File

@@ -36,7 +36,7 @@ import org.springframework.webflow.definition.FlowDefinition;
import org.springframework.webflow.definition.StateDefinition;
import org.springframework.webflow.definition.TransitionDefinition;
import org.springframework.webflow.execution.EnterStateVetoException;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.FlowExecutionListener;
import org.springframework.webflow.execution.RequestContext;
/**
@@ -44,7 +44,7 @@ import org.springframework.webflow.execution.RequestContext;
*
* @author Scott Andrews
*/
public class SecurityFlowExecutionListener extends FlowExecutionListenerAdapter {
public class SecurityFlowExecutionListener implements FlowExecutionListener {
private static final boolean SPRING_SECURITY_3_PRESENT = ClassUtils.hasConstructor(AffirmativeBased.class);

View File

@@ -2,6 +2,7 @@ package org.springframework.webflow.action;
import junit.framework.TestCase;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.support.StaticExpression;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.View;
@@ -22,7 +23,7 @@ public class RenderActionTests extends TestCase {
public void testIllegalNullArg() {
try {
new RenderAction(null);
new RenderAction((Expression[]) null);
fail("iae");
} catch (IllegalArgumentException e) {

View File

@@ -10,7 +10,7 @@ import org.springframework.webflow.conversation.ConversationManager;
import org.springframework.webflow.conversation.ConversationParameters;
import org.springframework.webflow.core.collection.AttributeMap;
import org.springframework.webflow.definition.FlowDefinition;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.FlowExecutionListener;
import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.executor.FlowExecutor;
import org.springframework.webflow.executor.FlowExecutorImpl;
@@ -43,7 +43,7 @@ public abstract class AbstractFlowExecutorConfigurationTests extends TestCase {
}
}
public static class ConfigurationListener extends FlowExecutionListenerAdapter {
public static class ConfigurationListener implements FlowExecutionListener {
public void sessionCreating(RequestContext context, FlowDefinition definition) {
AttributeMap<Object> attributes = context.getFlowExecutionContext().getAttributes();

View File

@@ -16,7 +16,6 @@ import org.springframework.webflow.engine.Transition;
import org.springframework.webflow.engine.ViewState;
import org.springframework.webflow.engine.support.DefaultTargetStateResolver;
import org.springframework.webflow.execution.FlowExecutionListener;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.factory.StaticFlowExecutionListenerLoader;
public class FlowExecutorFactoryBeanTests extends TestCase {
@@ -57,9 +56,7 @@ public class FlowExecutorFactoryBeanTests extends TestCase {
Set<FlowElementAttribute> attributes = new HashSet<>();
attributes.add(new FlowElementAttribute("foo", "bar", null));
factoryBean.setFlowExecutionAttributes(attributes);
FlowExecutionListener listener = new FlowExecutionListenerAdapter() {
};
FlowExecutionListener listener = new FlowExecutionListener() {};
factoryBean.setFlowExecutionListenerLoader(new StaticFlowExecutionListenerLoader(listener));
factoryBean.setMaxFlowExecutionSnapshots(2);
factoryBean.setMaxFlowExecutions(1);

View File

@@ -19,8 +19,6 @@ import org.springframework.webflow.engine.ViewState;
import org.springframework.webflow.engine.builder.FlowAssembler;
import org.springframework.webflow.engine.builder.FlowBuilderException;
import org.springframework.webflow.engine.impl.FlowExecutionImplFactory;
import org.springframework.webflow.engine.model.AbstractActionModel;
import org.springframework.webflow.engine.model.AbstractStateModel;
import org.springframework.webflow.engine.model.AttributeModel;
import org.springframework.webflow.engine.model.EndStateModel;
import org.springframework.webflow.engine.model.EvaluateModel;
@@ -67,19 +65,20 @@ public class FlowModelFlowBuilderTests extends TestCase {
}
}
private <T> LinkedList<T> asList(Class<T> elementClass, T... a) {
@SuppressWarnings("unchecked")
private <T> LinkedList<T> asList(T... a) {
return new LinkedList<>(Arrays.asList(a));
}
public void testBuildFlowWithEndState() {
model.setStates(asList(AbstractStateModel.class, new EndStateModel("end")));
model.setStates(asList(new EndStateModel("end")));
Flow flow = getFlow(model);
assertEquals("flow", flow.getId());
assertEquals("end", flow.getStartState().getId());
}
public void testBuildFlowWithDefaultStartState() {
model.setStates(asList(AbstractStateModel.class, new EndStateModel("end")));
model.setStates(asList(new EndStateModel("end")));
Flow flow = getFlow(model);
assertEquals("flow", flow.getId());
assertEquals("end", flow.getStartState().getId());
@@ -87,7 +86,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testBuildFlowWithStartStateAttribute() {
model.setStartStateId("end");
model.setStates(asList(AbstractStateModel.class, new EndStateModel("foo"), new EndStateModel("end")));
model.setStates(asList(new EndStateModel("foo"), new EndStateModel("end")));
Flow flow = getFlow(model);
assertEquals("flow", flow.getId());
assertEquals("end", flow.getStartState().getId());
@@ -97,9 +96,9 @@ public class FlowModelFlowBuilderTests extends TestCase {
AttributeModel attribute1 = new AttributeModel("foo", "bar");
AttributeModel attribute2 = new AttributeModel("number", "1");
attribute2.setType("integer");
model.setAttributes(asList(AttributeModel.class, attribute1, attribute2));
model.setAttributes(asList(attribute1, attribute2));
model.setStates(asList(AbstractStateModel.class, new EndStateModel("end")));
model.setStates(asList(new EndStateModel("end")));
Flow flow = getFlow(model);
assertEquals("bar", flow.getAttributes().get("foo"));
assertEquals(1, flow.getAttributes().get("number"));
@@ -107,7 +106,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testPersistenceContextFlow() {
model.setPersistenceContext(new PersistenceContextModel());
model.setStates(asList(AbstractStateModel.class, new EndStateModel("end")));
model.setStates(asList(new EndStateModel("end")));
Flow flow = getFlow(model);
assertNotNull(flow.getAttributes().get("persistenceContext"));
assertTrue((Boolean) flow.getAttributes().get("persistenceContext"));
@@ -120,7 +119,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
input3.setType("integer");
InputModel input4 = new InputModel("required", "flowScope.boop");
input4.setRequired("true");
model.setInputs(asList(InputModel.class, input1, input2, input3, input4));
model.setInputs(asList(input1, input2, input3, input4));
OutputModel output1 = new OutputModel("differentName", "flowScope.bar");
OutputModel output2 = new OutputModel("number", "flowScope.baz");
@@ -129,15 +128,15 @@ public class FlowModelFlowBuilderTests extends TestCase {
output3.setType("integer");
output3.setRequired("true");
OutputModel output4 = new OutputModel("literal", "'a literal'");
model.setOutputs(asList(OutputModel.class, output1, output2, output3, output4));
model.setOutputs(asList(output1, output2, output3, output4));
EndStateModel end = new EndStateModel("end");
end.setOutputs(asList(OutputModel.class, new OutputModel("foo", "flowScope.foo")));
end.setOutputs(asList(new OutputModel("foo", "flowScope.foo")));
EndStateModel notReached = new EndStateModel("notReached");
notReached.setOutputs(asList(OutputModel.class, new OutputModel("notReached", "flowScope.foo")));
notReached.setOutputs(asList(new OutputModel("notReached", "flowScope.foo")));
model.setStates(asList(AbstractStateModel.class, end, notReached));
model.setStates(asList(end, notReached));
Flow flow = getFlow(model);
FlowExecutionImplFactory factory = new FlowExecutionImplFactory();
@@ -160,7 +159,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testFlowSecured() {
model.setSecured(new SecuredModel("ROLE_USER"));
model.setStates(asList(AbstractStateModel.class, new EndStateModel("end")));
model.setStates(asList(new EndStateModel("end")));
Flow flow = getFlow(model);
SecurityRule rule = (SecurityRule) flow.getAttributes().get(SecurityRule.SECURITY_ATTRIBUTE_NAME);
assertNotNull(rule);
@@ -172,7 +171,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testFlowSecuredState() {
EndStateModel end = new EndStateModel("end");
end.setSecured(new SecuredModel("ROLE_USER"));
model.setStates(asList(AbstractStateModel.class, end));
model.setStates(asList(end));
Flow flow = getFlow(model);
SecurityRule rule = (SecurityRule) flow.getState("end").getAttributes()
.get(SecurityRule.SECURITY_ATTRIBUTE_NAME);
@@ -183,11 +182,11 @@ public class FlowModelFlowBuilderTests extends TestCase {
}
public void testFlowSecuredTransition() {
model.setStates(asList(AbstractStateModel.class, new EndStateModel("end")));
model.setStates(asList(new EndStateModel("end")));
TransitionModel transition = new TransitionModel();
transition.setTo("end");
transition.setSecured(new SecuredModel("ROLE_USER"));
model.setGlobalTransitions(asList(TransitionModel.class, transition));
model.setGlobalTransitions(asList(transition));
Flow flow = getFlow(model);
SecurityRule rule = (SecurityRule) flow.getGlobalTransitionSet().toArray()[0].getAttributes().get(
SecurityRule.SECURITY_ATTRIBUTE_NAME);
@@ -198,16 +197,16 @@ public class FlowModelFlowBuilderTests extends TestCase {
}
public void testFlowVariable() {
model.setVars(asList(VarModel.class, new VarModel("flow-foo", "org.springframework.webflow.TestBean")));
model.setStates(asList(AbstractStateModel.class, new EndStateModel("end")));
model.setVars(asList(new VarModel("flow-foo", "org.springframework.webflow.TestBean")));
model.setStates(asList(new EndStateModel("end")));
Flow flow = getFlow(model);
assertEquals("flow-foo", flow.getVariable("flow-foo").getName());
}
public void testViewStateVariable() {
ViewStateModel view = new ViewStateModel("view");
view.setVars(asList(VarModel.class, new VarModel("foo", "org.springframework.webflow.TestBean")));
model.setStates(asList(AbstractStateModel.class, view));
view.setVars(asList(new VarModel("foo", "org.springframework.webflow.TestBean")));
model.setStates(asList(view));
Flow flow = getFlow(model);
assertNotNull(((ViewState) flow.getStateInstance("view")).getVariable("foo"));
}
@@ -215,7 +214,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testViewStateRedirect() {
ViewStateModel view = new ViewStateModel("view");
view.setRedirect("true");
model.setStates(asList(AbstractStateModel.class, view));
model.setStates(asList(view));
Flow flow = getFlow(model);
assertTrue(((ViewState) flow.getStateInstance("view")).getRedirect());
}
@@ -223,7 +222,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testViewStatePopup() {
ViewStateModel view = new ViewStateModel("view");
view.setPopup("true");
model.setStates(asList(AbstractStateModel.class, view));
model.setStates(asList(view));
Flow flow = getFlow(model);
assertTrue(((ViewState) flow.getStateInstance("view")).getPopup());
}
@@ -231,7 +230,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testViewStateFlowRedirect() {
ViewStateModel state = new ViewStateModel("view");
state.setView("flowRedirect:myFlow?input=#{flowScope.foo}");
model.setStates(asList(AbstractStateModel.class, state));
model.setStates(asList(state));
Flow flow = getFlow(model);
ViewFactory vf = ((ViewState) flow.getStateInstance("view")).getViewFactory();
assertTrue(vf instanceof ActionExecutingViewFactory);
@@ -242,7 +241,7 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testViewStateExternalRedirect() {
ViewStateModel state = new ViewStateModel("view");
state.setView("externalRedirect:http://www.paypal.com?_callbackUrl=#{flowExecutionUri}");
model.setStates(asList(AbstractStateModel.class, state));
model.setStates(asList(state));
Flow flow = getFlow(model);
ViewFactory vf = ((ViewState) flow.getStateInstance("view")).getViewFactory();
assertTrue(vf instanceof ActionExecutingViewFactory);
@@ -276,8 +275,8 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testExceptionHandlers() {
FlowModel model = new FlowModel();
model.setStates(asList(AbstractStateModel.class, new EndStateModel("state")));
model.setExceptionHandlers(asList(ExceptionHandlerModel.class, new ExceptionHandlerModel("exceptionHandler")));
model.setStates(asList(new EndStateModel("state")));
model.setExceptionHandlers(asList(new ExceptionHandlerModel("exceptionHandler")));
FlowExecutionExceptionHandler handler = new FlowExecutionExceptionHandler() {
public boolean canHandle(FlowExecutionException exception) {
return true;
@@ -297,8 +296,8 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testSetActionWithResultType() throws Exception {
SetModel setModel = new SetModel("flowScope.stringArray", "intArray");
setModel.setType("java.lang.String[]");
model.setOnStartActions(asList(AbstractActionModel.class, setModel));
model.setStates(asList(AbstractStateModel.class, new ViewStateModel("view")));
model.setOnStartActions(asList(setModel));
model.setStates(asList(new ViewStateModel("view")));
Flow flow = getFlow(model);
AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0);
MockRequestContext context = new MockRequestContext(flow);
@@ -311,9 +310,9 @@ public class FlowModelFlowBuilderTests extends TestCase {
public void testSetActionWithImplicitTypeConversion() throws Exception {
SetModel setModel = new SetModel("testBean.stringArray", "intArray");
model.setOnStartActions(asList(AbstractActionModel.class, setModel));
model.setOnStartActions(asList(setModel));
ViewStateModel state = new ViewStateModel("view");
model.setStates(asList(AbstractStateModel.class, state));
model.setStates(asList(state));
Flow flow = getFlow(model);
AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0);
MockRequestContext context = new MockRequestContext(flow);
@@ -329,8 +328,8 @@ public class FlowModelFlowBuilderTests extends TestCase {
EvaluateModel evaluateModel = new EvaluateModel("testBean.getIntegers()");
evaluateModel.setResult("flowScope.stringArray");
evaluateModel.setResultType("java.lang.String[]");
model.setOnStartActions(asList(AbstractActionModel.class, evaluateModel));
model.setStates(asList(AbstractStateModel.class, new ViewStateModel("view")));
model.setOnStartActions(asList(evaluateModel));
model.setStates(asList(new ViewStateModel("view")));
Flow flow = getFlow(model);
AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0);
MockRequestContext context = new MockRequestContext(flow);
@@ -345,8 +344,8 @@ public class FlowModelFlowBuilderTests extends TestCase {
EvaluateModel evaluateModel = new EvaluateModel("testBean.getIntegers()");
evaluateModel.setResult("flowScope.stringArray");
evaluateModel.setResultType("java.lang.String[]");
model.setOnStartActions(asList(AbstractActionModel.class, evaluateModel));
model.setStates(asList(AbstractStateModel.class, new ViewStateModel("view")));
model.setOnStartActions(asList(evaluateModel));
model.setStates(asList(new ViewStateModel("view")));
Flow flow = getFlow(model);
AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0);
MockRequestContext context = new MockRequestContext(flow);

View File

@@ -32,7 +32,6 @@ import org.springframework.webflow.execution.FlowExecutionException;
import org.springframework.webflow.execution.FlowExecutionKey;
import org.springframework.webflow.execution.FlowExecutionKeyFactory;
import org.springframework.webflow.execution.FlowExecutionListener;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.FlowSession;
import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.execution.factory.StaticFlowExecutionListenerLoader;
@@ -89,7 +88,7 @@ public class FlowExecutionImplFactoryTests extends TestCase {
}
public void testCreateWithExecutionListener() {
FlowExecutionListener listener1 = new FlowExecutionListenerAdapter() {
FlowExecutionListener listener1 = new FlowExecutionListener() {
public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap<?> input) {
starting = true;
}
@@ -125,7 +124,7 @@ public class FlowExecutionImplFactoryTests extends TestCase {
FlowExecutionImpl flowExecution = (FlowExecutionImpl) factory.createFlowExecution(flowDefinition);
LocalAttributeMap<Object> executionAttributes = new LocalAttributeMap<>();
factory.setExecutionAttributes(executionAttributes);
FlowExecutionListener listener = new FlowExecutionListenerAdapter() {
FlowExecutionListener listener = new FlowExecutionListener() {
};
factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(listener));
MockFlowExecutionKeyFactory keyFactory = new MockFlowExecutionKeyFactory();

View File

@@ -31,7 +31,6 @@ import org.springframework.webflow.engine.ViewState;
import org.springframework.webflow.engine.support.DefaultTargetStateResolver;
import org.springframework.webflow.execution.FlowExecutionException;
import org.springframework.webflow.execution.FlowExecutionListener;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.FlowSession;
import org.springframework.webflow.execution.MockFlowExecutionListener;
import org.springframework.webflow.execution.RequestContext;
@@ -159,7 +158,7 @@ public class FlowExecutionImplTests extends TestCase {
});
new EndState(flow, "end");
FlowExecutionListener mockListener = new FlowExecutionListenerAdapter() {
FlowExecutionListener mockListener = new FlowExecutionListener() {
public void sessionCreating(RequestContext context, FlowDefinition definition) {
assertFalse(context.getFlowExecutionContext().isActive());
throw new IllegalStateException("Oops");

View File

@@ -39,13 +39,13 @@ public class FlowModelTests extends TestCase {
public void testMergeAttributes() {
FlowModel child = new FlowModel();
FlowModel parent = new FlowModel();
child.setAttributes(asList(AttributeModel.class, new AttributeModel("name", "value")));
child.setAttributes(asList(new AttributeModel("name", "value")));
AttributeModel parentAttribute1 = new AttributeModel("name", "value");
parentAttribute1.setType("type");
AttributeModel parentAttribute2 = new AttributeModel("name2", "value2");
parentAttribute2.setType("type2");
parent.setAttributes(asList(AttributeModel.class, parentAttribute1, parentAttribute2));
parent.setAttributes(asList(parentAttribute1, parentAttribute2));
child.merge(parent);
assertEquals(2, child.getAttributes().size());
@@ -76,10 +76,10 @@ public class FlowModelTests extends TestCase {
public void testMergeVars() {
FlowModel parent = new FlowModel();
parent.setVars(asList(VarModel.class, new VarModel("name", "value")));
parent.setVars(asList(new VarModel("name", "value")));
FlowModel child = new FlowModel();
child.setVars(asList(VarModel.class, new VarModel("name", "value2")));
child.setVars(asList(new VarModel("name", "value2")));
child.merge(parent);
assertEquals(1, child.getVars().size());
@@ -102,12 +102,12 @@ public class FlowModelTests extends TestCase {
input2.setType("type3");
input2.setRequired("required3");
child.setInputs(asList(InputModel.class, input1, input2, input3));
child.setInputs(asList(input1, input2, input3));
InputModel parentInput = new InputModel("name3", "value3");
parentInput.setType("type3");
parentInput.setRequired("required3");
parent.setInputs(asList(InputModel.class, parentInput));
parent.setInputs(asList(parentInput));
child.merge(parent);
assertEquals(3, child.getInputs().size());
@@ -115,14 +115,14 @@ public class FlowModelTests extends TestCase {
public void testMergeOnStart() {
FlowModel child = new FlowModel();
child.setOnStartActions(asList(AbstractActionModel.class, new EvaluateModel("expression"), new RenderModel(
child.setOnStartActions(asList(new EvaluateModel("expression"), new RenderModel(
"expression"), new SetModel("expression", "value")));
FlowModel parent = new FlowModel();
EvaluateModel eval = new EvaluateModel("expression");
eval.setResult("result");
parent.setOnStartActions(asList(AbstractActionModel.class, eval, new RenderModel("expression"), new SetModel(
parent.setOnStartActions(asList(eval, new RenderModel("expression"), new SetModel(
"expression", "value")));
child.merge(parent);
@@ -132,12 +132,12 @@ public class FlowModelTests extends TestCase {
public void testMergeStates() {
FlowModel child = new FlowModel();
child.setStates(asList(AbstractStateModel.class, new ViewStateModel("view"), new EndStateModel("end")));
child.setStates(asList(new ViewStateModel("view"), new EndStateModel("end")));
FlowModel parent = new FlowModel();
ViewStateModel view = new ViewStateModel("view");
view.setView("jsp");
parent.setStates(asList(AbstractStateModel.class, view, new DecisionStateModel("decider"),
parent.setStates(asList(view, new DecisionStateModel("decider"),
new ActionStateModel("action")));
child.merge(parent);
@@ -151,7 +151,7 @@ public class FlowModelTests extends TestCase {
transition1.setOn("end");
TransitionModel transition2 = new TransitionModel();
transition2.setOn("start");
child.setGlobalTransitions(asList(TransitionModel.class, transition1, transition2));
child.setGlobalTransitions(asList(transition1, transition2));
FlowModel parent = new FlowModel();
transition1 = new TransitionModel();
@@ -159,7 +159,7 @@ public class FlowModelTests extends TestCase {
transition2 = new TransitionModel();
transition2.setOn("end");
transition2.setTo("theend");
parent.setGlobalTransitions(asList(TransitionModel.class, transition1, transition2));
parent.setGlobalTransitions(asList(transition1, transition2));
child.merge(parent);
assertEquals(3, child.getGlobalTransitions().size());
@@ -168,13 +168,13 @@ public class FlowModelTests extends TestCase {
public void testMergeOnEnd() {
FlowModel child = new FlowModel();
child.setOnEndActions(asList(AbstractActionModel.class, new EvaluateModel("expression"), new RenderModel(
"expression"), new SetModel("expression", "value")));
child.setOnEndActions(asList(new EvaluateModel("expression"), new RenderModel("expression"),
new SetModel("expression", "value")));
FlowModel parent = new FlowModel();
EvaluateModel eval = new EvaluateModel("expression");
eval.setResult("result");
parent.setOnEndActions(asList(AbstractActionModel.class, eval, new RenderModel("expression"), new SetModel(
parent.setOnEndActions(asList(eval, new RenderModel("expression"), new SetModel(
"expression", "value")));
child.merge(parent);
@@ -184,12 +184,11 @@ public class FlowModelTests extends TestCase {
public void testMergeExceptionHandlers() {
FlowModel child = new FlowModel();
child.setExceptionHandlers(asList(ExceptionHandlerModel.class, new ExceptionHandlerModel("bean1"),
child.setExceptionHandlers(asList(new ExceptionHandlerModel("bean1"),
new ExceptionHandlerModel("bean2")));
FlowModel parent = new FlowModel();
parent.setExceptionHandlers(asList(ExceptionHandlerModel.class, new ExceptionHandlerModel("bean2"),
new ExceptionHandlerModel("bean3")));
parent.setExceptionHandlers(asList(new ExceptionHandlerModel("bean2"), new ExceptionHandlerModel("bean3")));
child.merge(parent);
assertEquals(4, child.getExceptionHandlers().size());
@@ -197,16 +196,17 @@ public class FlowModelTests extends TestCase {
public void testMergeBeanImports() {
FlowModel child = new FlowModel();
child.setBeanImports(asList(BeanImportModel.class, new BeanImportModel("path1"), new BeanImportModel("path2")));
child.setBeanImports(asList(new BeanImportModel("path1"), new BeanImportModel("path2")));
FlowModel parent = new FlowModel();
parent.setBeanImports(asList(BeanImportModel.class, new BeanImportModel("path1"), new BeanImportModel("path2")));
parent.setBeanImports(asList(new BeanImportModel("path1"), new BeanImportModel("path2")));
child.merge(parent);
assertEquals(4, child.getBeanImports().size());
}
private <T> LinkedList<T> asList(Class<T> elementClass, T... a) {
@SuppressWarnings("unchecked")
private <T> LinkedList<T> asList(T... a) {
return new LinkedList<>(Arrays.asList(a));
}

View File

@@ -22,7 +22,7 @@ import org.springframework.webflow.engine.model.builder.FlowModelBuilderExceptio
import org.springframework.webflow.engine.model.registry.FlowModelRegistry;
import org.springframework.webflow.engine.model.registry.FlowModelRegistryImpl;
import org.springframework.webflow.execution.FlowExecution;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.FlowExecutionListener;
import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.execution.View;
import org.springframework.webflow.execution.factory.StaticFlowExecutionListenerLoader;
@@ -301,7 +301,7 @@ public class XmlFlowModelBuilderTests extends TestCase {
FlowAssembler assembler = new FlowAssembler(flowBuilder, new MockFlowBuilderContext("flow"));
Flow flow = assembler.assembleFlow();
FlowExecutionImplFactory factory = new FlowExecutionImplFactory();
factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(new FlowExecutionListenerAdapter() {
factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(new FlowExecutionListener() {
public void viewRendering(RequestContext context, View view, StateDefinition viewState) {
if (context.getCurrentEvent() != null && context.getCurrentEvent().getId().equals("submit")) {
BindingResult result = (BindingResult) context.getFlashScope().get(

View File

@@ -71,7 +71,7 @@ public class TransitionCriteriaChainTests extends TestCase {
}
public void testCriteriaChainForNoActions() {
TransitionCriteria actionChain = TransitionCriteriaChain.criteriaChainFor(null);
TransitionCriteria actionChain = TransitionCriteriaChain.criteriaChainFor((Action[]) null);
assertTrue(actionChain.test(context));
}

View File

@@ -36,7 +36,6 @@ import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.FlowExecution;
import org.springframework.webflow.execution.FlowExecutionException;
import org.springframework.webflow.execution.FlowExecutionListener;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.FlowSession;
import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.execution.factory.StaticFlowExecutionListenerLoader;
@@ -85,7 +84,7 @@ public class TransitionExecutingFlowExecutionExceptionHandlerTests extends TestC
TransitionExecutingFlowExecutionExceptionHandler handler = new TransitionExecutingFlowExecutionExceptionHandler();
handler.add(TestException.class, "end");
flow.getExceptionHandlerSet().add(handler);
FlowExecutionListener listener = new FlowExecutionListenerAdapter() {
FlowExecutionListener listener = new FlowExecutionListener() {
@SuppressWarnings("unused")
public void sessionEnding(RequestContext context, FlowSession session, MutableAttributeMap<?> output) {
assertTrue(context.getFlashScope().contains("flowExecutionException"));

View File

@@ -29,7 +29,7 @@ import org.springframework.webflow.definition.TransitionDefinition;
* @author Erwin Vervaet
* @author Scott Andrews
*/
public class MockFlowExecutionListener extends FlowExecutionListenerAdapter {
public class MockFlowExecutionListener implements FlowExecutionListener {
private boolean sessionStarting;

View File

@@ -19,7 +19,6 @@ import junit.framework.TestCase;
import org.springframework.webflow.engine.Flow;
import org.springframework.webflow.execution.FlowExecutionListener;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
/**
* Unit tests for {@link ConditionalFlowExecutionListenerLoader}.
@@ -35,8 +34,7 @@ public class ConditionalFlowExecutionListenerLoaderTests extends TestCase {
}
public void testAddConditionalListener() {
FlowExecutionListenerAdapter listener = new FlowExecutionListenerAdapter() {
};
FlowExecutionListener listener = new FlowExecutionListener() {};
loader.addListener(listener, criteriaFactory.allFlows());
Flow flow = new Flow("foo");
FlowExecutionListener[] listeners = loader.getListeners(flow);
@@ -45,22 +43,19 @@ public class ConditionalFlowExecutionListenerLoaderTests extends TestCase {
}
public void testAddMultipleListeners() {
FlowExecutionListenerAdapter listener = new FlowExecutionListenerAdapter() {
};
FlowExecutionListenerAdapter listener2 = new FlowExecutionListenerAdapter() {
};
loader.addListener(listener, criteriaFactory.allFlows());
FlowExecutionListener listener1 = new FlowExecutionListener() {};
FlowExecutionListener listener2 = new FlowExecutionListener() {};
loader.addListener(listener1, criteriaFactory.allFlows());
loader.addListener(listener2, criteriaFactory.allFlows());
Flow flow = new Flow("foo");
FlowExecutionListener[] listeners = loader.getListeners(flow);
assertEquals(2, listeners.length);
assertSame(listener, listeners[0]);
assertSame(listener1, listeners[0]);
assertSame(listener2, listeners[1]);
}
public void testAddListenerButNoMatch() {
FlowExecutionListenerAdapter listener = new FlowExecutionListenerAdapter() {
};
FlowExecutionListener listener = new FlowExecutionListener() {};
loader.addListener(listener, criteriaFactory.flow("bar"));
Flow flow = new Flow("foo");
FlowExecutionListener[] listeners = loader.getListeners(flow);

View File

@@ -19,7 +19,6 @@ import junit.framework.TestCase;
import org.springframework.webflow.engine.Flow;
import org.springframework.webflow.execution.FlowExecutionListener;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
/**
* Unit tests for {@link StaticFlowExecutionListenerLoader}.
@@ -34,17 +33,14 @@ public class StaticFlowExecutionListenerLoaderTests extends TestCase {
}
public void testStaticListener() {
final FlowExecutionListener listener1 = new FlowExecutionListenerAdapter() {
};
final FlowExecutionListener listener1 = new FlowExecutionListener() {};
loader = new StaticFlowExecutionListenerLoader(listener1);
assertEquals(listener1, loader.getListeners(new Flow("foo"))[0]);
}
public void testStaticListeners() {
final FlowExecutionListener listener1 = new FlowExecutionListenerAdapter() {
};
final FlowExecutionListener listener2 = new FlowExecutionListenerAdapter() {
};
final FlowExecutionListener listener1 = new FlowExecutionListener() {};
final FlowExecutionListener listener2 = new FlowExecutionListener() {};
loader = new StaticFlowExecutionListenerLoader(listener1, listener2);
assertEquals(listener1, loader.getListeners(new Flow("foo"))[0]);