Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/
package org.restlet.ext.freemarker;

import static freemarker.template.Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
Expand Down Expand Up @@ -44,7 +43,8 @@ void testTemplate() throws Exception {
fw.write("Value=${value}");
fw.close();

final Configuration fmc = new Configuration(DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
final Configuration fmc =
new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
fmc.setDirectoryForTemplateLoading(testDir);
final Map<String, Object> map = Map.of("value", "myValue");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ protected void assertEquals(MyException me1, MyException me2) {
assertEquals(me1.getCustomer(), me2.getCustomer());
}

private String normalizeLineEndings(String text) {
return text.replace("\r\n", "\n").replace('\r', '\n');
}
private String normalizeLineEndings(String text) {
return text.replace("\r\n", "\n").replace('\r', '\n');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ && getApplicationContext().containsBean(requiredBeanName)) {
}
}

@NonNull
private String getRequiredBeanName() {
@NonNull private String getRequiredBeanName() {
String currentBeanName = getBeanName();
if (currentBeanName == null) {
throw new IllegalStateException("beanName");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,40 +270,35 @@ public void setApplicationContext(@NonNull ApplicationContext applicationContext
this.applicationContext = applicationContext;
}

@NonNull
private String requiredBeanName(String beanName) {
@NonNull private String requiredBeanName(String beanName) {
if (beanName == null) {
throw new IllegalStateException("beanName");
}
return beanName;
}

@NonNull
private BeanFactory requiredBeanFactory(BeanFactory beanFactory) {
@NonNull private BeanFactory requiredBeanFactory(BeanFactory beanFactory) {
if (beanFactory == null) {
throw new IllegalStateException("beanFactory");
}
return beanFactory;
}

@NonNull
private ListableBeanFactory requiredListableBeanFactory(ListableBeanFactory beanFactory) {
@NonNull private ListableBeanFactory requiredListableBeanFactory(ListableBeanFactory beanFactory) {
if (beanFactory == null) {
throw new IllegalStateException("beanFactory");
}
return beanFactory;
}

@NonNull
private Class<?> requiredBeanClass(Class<?> beanClass) {
@NonNull private Class<?> requiredBeanClass(Class<?> beanClass) {
if (beanClass == null) {
throw new IllegalStateException("beanClass");
}
return beanClass;
}

@NonNull
private ApplicationContext requiredApplicationContext() {
@NonNull private ApplicationContext requiredApplicationContext() {
ApplicationContext currentApplicationContext = this.applicationContext;
if (currentApplicationContext == null) {
throw new IllegalStateException("applicationContext");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ public boolean exists() {
* @return The description.
*/
@Override
@NonNull
public String getDescription() {
@NonNull public String getDescription() {
return this.description;
}

Expand All @@ -91,8 +90,7 @@ public String getDescription() {
* multiple times.
*/
@Override
@NonNull
public InputStream getInputStream() throws IOException, IllegalStateException {
@NonNull public InputStream getInputStream() throws IOException, IllegalStateException {
if (this.read && this.representation.isTransient()) {
throw new IllegalStateException(
"Representation has already been read and is transient.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,42 +205,37 @@ void testUsesApplicationContextIfPresent() {
assertInstanceOf(SomeResource.class, actual, "Resource not the correct type");
}

@NonNull
private StaticApplicationContext requiredApplicationContext() {
@NonNull private StaticApplicationContext requiredApplicationContext() {
StaticApplicationContext currentApplicationContext = this.applicationContext;
if (currentApplicationContext == null) {
throw new IllegalStateException("applicationContext");
}
return currentApplicationContext;
}

@NonNull
private DefaultListableBeanFactory requiredBeanFactory() {
@NonNull private DefaultListableBeanFactory requiredBeanFactory() {
DefaultListableBeanFactory currentBeanFactory = this.beanFactory;
if (currentBeanFactory == null) {
throw new IllegalStateException("beanFactory");
}
return currentBeanFactory;
}

@NonNull
private String requiredBeanName(String beanName) {
@NonNull private String requiredBeanName(String beanName) {
if (beanName == null) {
throw new IllegalStateException("beanName");
}
return beanName;
}

@NonNull
private Class<SomeResource> requiredResourceClass(Class<SomeResource> resourceClass) {
@NonNull private Class<SomeResource> requiredResourceClass(Class<SomeResource> resourceClass) {
if (resourceClass == null) {
throw new IllegalStateException("resourceClass");
}
return resourceClass;
}

@NonNull
private Class<?> requiredAnyClass(Class<?> resourceClass) {
@NonNull private Class<?> requiredAnyClass(Class<?> resourceClass) {
if (resourceClass == null) {
throw new IllegalStateException("resourceClass");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void tearDownEach() {
void testExplicitAttachmentsMayBeRestlets() {
String expected = "/protected/timber";
this.router.setAttachments(
Collections.singletonMap(requiredString(expected), requiredString("timber")));
Collections.singletonMap(requiredString(expected), requiredString("timber")));
registerBeanDefinition("timber", null, TestAuthenticator.class, null);

doPostProcess();
Expand All @@ -161,7 +161,7 @@ void testExplicitAttachmentsMayBeRestlets() {
@Test
void testExplicitAttachmentsTrumpBeanNames() {
this.router.setAttachments(
Collections.singletonMap(requiredString(ORE_URI), requiredString("fish")));
Collections.singletonMap(requiredString(ORE_URI), requiredString("fish")));
RouteList actualRoutes = actualRoutes();
assertEquals(2, actualRoutes.size(), "Wrong number of routes");

Expand All @@ -173,8 +173,7 @@ void testExplicitAttachmentsTrumpBeanNames() {
@Test
void testExplicitRoutingForNonResourceNonRestletBeansFails() {
this.router.setAttachments(
Collections.singletonMap(
requiredString("/fail"), requiredString("someOtherBean")));
Collections.singletonMap(requiredString("/fail"), requiredString("someOtherBean")));

IllegalStateException ise = assertThrows(IllegalStateException.class, this::doPostProcess);
assertEquals(
Expand Down Expand Up @@ -270,8 +269,8 @@ void testRoutingIncludesSpringRouterStyleExplicitlyMappedBeans() {

String expectedTemplate = "/renewable/timber/{farm_type}";
router.setAttachments(
Collections.singletonMap(
requiredString(expectedTemplate), requiredString("timber")));
Collections.singletonMap(
requiredString(expectedTemplate), requiredString("timber")));
final RouteList actualRoutes = actualRoutes();

assertEquals(3, actualRoutes.size(), "Wrong number of routes");
Expand Down
Loading
Loading