This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="evenIdFilter" | |
class="org.eyal.requestvalidation.flow.example.flow.itemsfilter.filters.EvenIdFilter"> | |
</bean> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<context:property-placeholder location="classpath:spring/flow.properties" /> | |
<bean id="longNameExternalFilter" | |
class="org.eyal.requestvalidation.flow.example.flow.itemsfilter.filters.NameTooLongFilter"> | |
<constructor-arg value="${filter.external.name.max}" /> | |
</bean> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Somewhere in a different utility class for testing | |
@SuppressWarnings("unchecked") | |
public static <T> T realObjectFromField(Class<?> clazz, String fieldName, Object object) { | |
Field declaredField = accessibleField(clazz, fieldName); | |
try { | |
return (T) declaredField.get(object); | |
} catch (IllegalArgumentException | IllegalAccessException e) { | |
throw new RuntimeException(e); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Item { | |
private final Map<String, Set<String>> attributes; | |
public Item(Map<String, Set<String>> attributes) { | |
this.attributes = attributes; | |
} | |
public Map<String, Set<String>> getAttributes() { | |
return attributes; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ItemSaver { | |
private String valueToSave; | |
public ItemSaver(String valueToSave) { | |
this.valueToSave = valueToSave; | |
} | |
public void doSomething(String attributeName, Item item) { | |
Set<String> attributeValues = item.getAttributes().get(attributeName); | |
for (String value : attributeValues) { | |
if (value.equals(valueToSave)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set<String> attributeValues = item.getAttributes().get(attributeName); | |
String singleValue = attributeValues.iterator().next(); | |
// String singleValue = item.getAttributes().get(attributeName).iterator().next(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Item item = mock(Item.class); | |
Map<String, Set<String>> attributes = mock(Map.class); | |
Set<String> values = mock(Set.class); | |
Iterator<String> iterator = mock(Iterator.class); | |
when(iterator.next()).thenReturn("the single value"); | |
when(values.iterator()).thenReturn(iterator); | |
when(attributes.containsKey("the-key")).thenReturn(true); | |
when(attributes.get("the-key")).thenReturn(values); | |
when(item.getAttributes()).thenReturn(attributes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Item { | |
private final Map<String, Set<String>> attributes; | |
public Item(Map<String, Set<String>> attributes) { | |
this.attributes = attributes; | |
} | |
public boolean attributeExists(String attributeName) { | |
return attributes.containsKey(attributeName); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Item item = mock(Item.class); | |
when(item.getSingleValue("the-key")).thenReturn("the single value"); |
OlderNewer