Polishing contribution

This commit is contained in:
Rossen Stoyanchev
2020-05-04 20:09:36 +01:00
parent 2be8bcbc18
commit 3bb4e6c3a7
23 changed files with 105 additions and 90 deletions

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.binding.collection;
import java.io.Serializable;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,13 +44,13 @@ public class DefaultMessageContext implements StateManageableMessageContext {
private MessageSource messageSource;
@SuppressWarnings("serial")
private Map<Object, List<Message>> sourceMessages = new AbstractCachingMapDecorator<Object, List<Message>>(
new LinkedHashMap<>()) {
private Map<Object, List<Message>> sourceMessages =
new AbstractCachingMapDecorator<Object, List<Message>>(new LinkedHashMap<>()) {
protected List<Message> create(Object source) {
return new ArrayList<>();
}
};
protected List<Message> create(Object source) {
return new ArrayList<>();
}
};
/**
* Creates a new default message context. Defaults to a message source that simply resolves default text and cannot

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2014 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2015 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import javax.el.ELContext;
import javax.faces.application.FacesMessage;
import javax.faces.context.ExternalContext;
@@ -38,7 +39,6 @@ import javax.faces.context.PartialViewContextFactory;
import javax.faces.lifecycle.Lifecycle;
import org.springframework.binding.message.Message;
import org.springframework.binding.message.MessageCriteria;
import org.springframework.binding.message.MessageResolver;
import org.springframework.binding.message.Severity;
import org.springframework.context.MessageSource;
@@ -230,8 +230,9 @@ public class FlowFacesContext extends FacesContextWrapper {
*/
public List<FacesMessage> getMessageList(final String clientId) {
final FacesMessageSource source = new FacesMessageSource(clientId);
Message[] messages = this.context.getMessageContext().getMessagesByCriteria(message -> ObjectUtils.nullSafeEquals(message.getSource(), source)
|| ObjectUtils.nullSafeEquals(message.getSource(), clientId));
Message[] messages = this.context.getMessageContext().getMessagesByCriteria(message ->
ObjectUtils.nullSafeEquals(message.getSource(), source)
|| ObjectUtils.nullSafeEquals(message.getSource(), clientId));
return asFacesMessages(messages);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2015 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,6 @@
package org.springframework.webflow.conversation.impl;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2008 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,9 +50,11 @@ public class FlowVariablePropertyAccessor implements PropertyAccessor {
private static Map<String, FlowVariableAccessor> variables = new HashMap<>();
static {
variables.put("currentUser", () -> RequestContextHolder.getRequestContext().getExternalContext().getCurrentUser());
variables.put("flowRequestContext", () -> RequestContextHolder.getRequestContext());
variables.put("resourceBundle", () -> RequestContextHolder.getRequestContext().getActiveFlow().getApplicationContext());
variables.put("currentUser", () ->
RequestContextHolder.getRequestContext().getExternalContext().getCurrentUser());
variables.put("flowRequestContext", RequestContextHolder::getRequestContext);
variables.put("resourceBundle", () ->
RequestContextHolder.getRequestContext().getActiveFlow().getApplicationContext());
}
public Class<?>[] getSpecificTargetClasses() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2018 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2015 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2008 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2012 the original author or authors.
* Copyright 2008-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,25 +53,25 @@ public class LocalAttributeMapTests {
attributeMap.put("collection", new LinkedList<>());
}
@Test
@Test
public void testGet() {
TestBean bean = (TestBean) attributeMap.get("bean");
assertNotNull(bean);
}
@Test
@Test
public void testGetNull() {
TestBean bean = (TestBean) attributeMap.get("bogus");
assertNull(bean);
}
@Test
@Test
public void testGetRequiredType() {
TestBean bean = attributeMap.get("bean", TestBean.class);
assertNotNull(bean);
}
@Test
@Test
public void testGetWrongType() {
try {
attributeMap.get("bean", String.class);
@@ -81,7 +81,7 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetWithDefaultOption() {
TestBean d = new TestBean();
TestBean bean = (TestBean) attributeMap.get("bean", d);
@@ -89,20 +89,20 @@ public class LocalAttributeMapTests {
assertNotSame(bean, d);
}
@Test
@Test
public void testGetWithDefault() {
TestBean d = new TestBean();
TestBean bean = (TestBean) attributeMap.get("bogus", d);
assertSame(bean, d);
}
@Test
@Test
public void testGetRequired() {
TestBean bean = (TestBean) attributeMap.getRequired("bean");
assertNotNull(bean);
}
@Test
@Test
public void testGetRequiredNotPresent() {
try {
attributeMap.getRequired("bogus");
@@ -112,13 +112,13 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetRequiredOfType() {
TestBean bean = attributeMap.getRequired("bean", TestBean.class);
assertNotNull(bean);
}
@Test
@Test
public void testGetRequiredWrongType() {
try {
attributeMap.getRequired("bean", String.class);
@@ -128,13 +128,13 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetNumber() {
BigDecimal bd = attributeMap.getNumber("bigDecimal", BigDecimal.class);
assertEquals(new BigDecimal("12345.67"), bd);
}
@Test
@Test
public void testGetNumberWrongType() {
try {
attributeMap.getNumber("bigDecimal", Integer.class);
@@ -144,7 +144,7 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetNumberWithDefaultOption() {
BigDecimal d = new BigDecimal("1");
BigDecimal bd = attributeMap.getNumber("bigDecimal", BigDecimal.class, d);
@@ -152,7 +152,7 @@ public class LocalAttributeMapTests {
assertNotSame(d, bd);
}
@Test
@Test
public void testGetNumberWithDefault() {
BigDecimal d = new BigDecimal("1");
BigDecimal bd = attributeMap.getNumber("bogus", BigDecimal.class, d);
@@ -160,13 +160,13 @@ public class LocalAttributeMapTests {
assertSame(d, bd);
}
@Test
@Test
public void testGetNumberRequired() {
BigDecimal bd = attributeMap.getRequiredNumber("bigDecimal", BigDecimal.class);
assertEquals(new BigDecimal("12345.67"), bd);
}
@Test
@Test
public void testGetNumberRequiredNotPresent() {
try {
attributeMap.getRequiredNumber("bogus", BigDecimal.class);
@@ -176,25 +176,25 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetInteger() {
Integer i = attributeMap.getInteger("integer");
assertEquals(new Integer(12345), i);
}
@Test
@Test
public void testGetIntegerNull() {
Integer i = attributeMap.getInteger("bogus");
assertNull(i);
}
@Test
@Test
public void testGetIntegerRequired() {
Integer i = attributeMap.getRequiredInteger("integer");
assertEquals(new Integer(12345), i);
}
@Test
@Test
public void testGetIntegerRequiredNotPresent() {
try {
attributeMap.getRequiredInteger("bogus");
@@ -204,25 +204,25 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetLong() {
Long i = attributeMap.getLong("long");
assertEquals(new Long(12345), i);
}
@Test
@Test
public void testGetLongNull() {
Long i = attributeMap.getLong("bogus");
assertNull(i);
}
@Test
@Test
public void testGetLongRequired() {
Long i = attributeMap.getRequiredLong("long");
assertEquals(new Long(12345), i);
}
@Test
@Test
public void testGetLongRequiredNotPresent() {
try {
attributeMap.getRequiredLong("bogus");
@@ -232,25 +232,25 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetString() {
String i = attributeMap.getString("string");
assertEquals("A string", i);
}
@Test
@Test
public void testGetStringNull() {
String i = attributeMap.getString("bogus");
assertNull(i);
}
@Test
@Test
public void testGetStringRequired() {
String i = attributeMap.getRequiredString("string");
assertEquals("A string", i);
}
@Test
@Test
public void testGetStringRequiredNotPresent() {
try {
attributeMap.getRequiredString("bogus");
@@ -260,25 +260,25 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetBoolean() {
Boolean i = attributeMap.getBoolean("boolean");
assertEquals(Boolean.TRUE, i);
}
@Test
@Test
public void testGetBooleanNull() {
Boolean i = attributeMap.getBoolean("bogus");
assertNull(i);
}
@Test
@Test
public void testGetBooleanRequired() {
Boolean i = attributeMap.getRequiredBoolean("boolean");
assertEquals(Boolean.TRUE, i);
}
@Test
@Test
public void testGetBooleanRequiredNotPresent() {
try {
attributeMap.getRequiredBoolean("bogus");
@@ -288,25 +288,25 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetArray() {
String[] i = attributeMap.getArray("stringArray", String[].class);
assertEquals(3, i.length);
}
@Test
@Test
public void testGetArrayNull() {
String[] i = attributeMap.getArray("A bogus array", String[].class);
assertNull(i);
}
@Test
@Test
public void testGetArrayRequired() {
String[] i = attributeMap.getRequiredArray("stringArray", String[].class);
assertEquals(3, i.length);
}
@Test
@Test
public void testGetArrayRequiredNotPresent() {
try {
attributeMap.getRequiredArray("A bogus array", String[].class);
@@ -317,7 +317,7 @@ public class LocalAttributeMapTests {
}
@SuppressWarnings("unchecked")
@Test
@Test
public void testGetCollection() {
List<Object> i = attributeMap.getCollection("collection", List.class);
assertTrue(i instanceof LinkedList);
@@ -325,20 +325,20 @@ public class LocalAttributeMapTests {
}
@SuppressWarnings("unchecked")
@Test
@Test
public void testGetCollectionNull() {
List<Object> i = attributeMap.getCollection("bogus", List.class);
assertNull(i);
}
@SuppressWarnings("unchecked")
@Test
@Test
public void testGetCollectionRequired() {
List<Object> i = attributeMap.getRequiredCollection("collection", List.class);
assertEquals(0, i.size());
}
@Test
@Test
public void testGetCollectionRequiredNotPresent() {
try {
attributeMap.getRequiredCollection("A bogus collection");
@@ -348,13 +348,13 @@ public class LocalAttributeMapTests {
}
}
@Test
@Test
public void testGetMap() {
Map<String, Object> map = attributeMap.asMap();
assertEquals(10, map.size());
}
@Test
@Test
public void testUnion() {
LocalAttributeMap<Object> one = new LocalAttributeMap<>();
one.put("foo", "bar");
@@ -371,7 +371,7 @@ public class LocalAttributeMapTests {
assertEquals("boo", three.get("bar"));
}
@Test
@Test
public void testEquality() {
LocalAttributeMap<String> map = new LocalAttributeMap<>();
map.put("foo", "bar");
@@ -382,7 +382,7 @@ public class LocalAttributeMapTests {
assertEquals(map, map2);
}
@Test
@Test
public void testExtract() {
assertEquals("A string", attributeMap.extract("string"));
assertFalse(attributeMap.contains("string"));

View File

@@ -1,19 +1,14 @@
package org.springframework.webflow.expression.el;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.el.ELResolver;
import javax.el.PropertyNotWritableException;
import org.junit.jupiter.api.Test;
import org.springframework.binding.message.MessageContext;
import org.springframework.util.ClassUtils;
import org.springframework.webflow.context.ExternalContext;
@@ -27,6 +22,11 @@ import org.springframework.webflow.test.MockFlowExecutionContext;
import org.springframework.webflow.test.MockFlowExecutionKey;
import org.springframework.webflow.test.MockRequestContext;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
public class ImplicitFlowVariableELResolverTests extends FlowDependentELResolverTestCase {
private static final List<String> vars = new ArrayList<>();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,20 +15,19 @@
*/
package org.springframework.webflow.expression.spel;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.webflow.engine.ViewState;
import org.springframework.webflow.execution.RequestContext;
import org.springframework.webflow.execution.View;
import org.springframework.webflow.execution.ViewFactory;
import org.springframework.webflow.test.MockFlowSession;
import org.springframework.webflow.test.MockRequestContext;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
public class ScopeSearchingPropertyAccessorTests {
private ScopeSearchingPropertyAccessor accessor = new ScopeSearchingPropertyAccessor();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.