Skip to content

Commit 1fc96c4

Browse files
committed
mvc: keep annotation name (don't lower case it) Fix jooby-project#1199
1 parent 00892a4 commit 1fc96c4

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

jooby/src/main/java/org/jooby/Route.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ private boolean valid(final Object value) {
15751575
if (value instanceof String || value instanceof Enum || value instanceof Class) {
15761576
return true;
15771577
}
1578-
if (value.getClass().isArray()) {
1578+
if (value.getClass().isArray() && Array.getLength(value) > 0) {
15791579
return valid(Array.get(value, 0));
15801580
}
15811581
if (value instanceof Map && ((Map) value).size() > 0) {

jooby/src/main/java/org/jooby/internal/mvc/MvcRoutes.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@
203203
*/
204204
package org.jooby.internal.mvc;
205205

206-
import com.google.common.base.CaseFormat;
207206
import com.google.common.collect.ImmutableSet;
208207
import org.jooby.Env;
209208
import org.jooby.MediaType;
@@ -391,8 +390,7 @@ private static Map<String, Object> attrs(final Annotation annotation) {
391390
private static String attrName(final Annotation annotation, final Method attr) {
392391
String name = attr.getName();
393392
if (name.equals("value")) {
394-
return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL,
395-
annotation.annotationType().getSimpleName());
393+
return annotation.annotationType().getSimpleName();
396394
}
397395
return annotation.annotationType().getSimpleName() + "." + name;
398396
}

jooby/src/test/java/org/jooby/internal/mvc/MvcHandlerTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
package org.jooby.internal.mvc;
22

33
import static org.easymock.EasyMock.expect;
4-
5-
import java.io.IOException;
6-
import java.lang.reflect.Method;
7-
import java.util.Collections;
8-
import java.util.List;
9-
104
import org.jooby.Request;
115
import org.jooby.Response;
126
import org.jooby.Route;
@@ -17,6 +11,11 @@
1711
import org.powermock.core.classloader.annotations.PrepareForTest;
1812
import org.powermock.modules.junit4.PowerMockRunner;
1913

14+
import java.io.IOException;
15+
import java.lang.reflect.Method;
16+
import java.util.Collections;
17+
import java.util.List;
18+
2019
@RunWith(PowerMockRunner.class)
2120
@PrepareForTest({MvcHandler.class })
2221
public class MvcHandlerTest {
@@ -120,7 +119,7 @@ public void handleException() throws Exception {
120119
}
121120

122121
@SuppressWarnings({"rawtypes", "unchecked" })
123-
@Test(expected = RuntimeException.class)
122+
@Test(expected = Throwable.class)
124123
public void throwableException() throws Exception {
125124
Class handlerClass = MvcHandlerTest.class;
126125
MvcHandlerTest handler = new MvcHandlerTest();

modules/coverage-report/src/test/java/org/jooby/issues/Issue346.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public Object admin(final Request req) {
6868
});
6969

7070
use("/3", (req, rsp) -> {
71-
assertEquals(ImmutableMap.of("SitemapUrl.priority", 0.5, "SitemapUrl.changefreq", "always", "role", "admin"),
71+
assertEquals(ImmutableMap.of("SitemapUrl.priority", 0.5, "SitemapUrl.changefreq", "always", "Role", "admin"),
7272
req.route().attributes());
7373
});
7474
use(Resource.class);
@@ -91,7 +91,7 @@ public void mvcAttrs() throws Exception {
9191
request().get("/3")
9292
.expect(value -> {
9393
Map<String, Object> hash = toMap(value.substring(1, value.length() - 1));
94-
assertEquals(ImmutableMap.of("SitemapUrl.priority", "0.5", "SitemapUrl.changefreq", "always", "role", "admin"),
94+
assertEquals(ImmutableMap.of("SitemapUrl.priority", "0.5", "SitemapUrl.changefreq", "always", "Role", "admin"),
9595
hash);
9696
});
9797
}

modules/jooby-apitool/src/main/java/org/jooby/internal/apitool/SwaggerBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ public Swagger build(Swagger base, final List<RouteMethod> routes) throws Except
451451

452452
private void buildResponse(RouteMethod route, Function<Type, Model> modelFactory,
453453
Consumer<ResponseWithStatusCode> consumer) {
454-
Object[] apiResponses = (Object[]) route.attributes().get("apiResponses");
454+
Object[] apiResponses = (Object[]) route.attributes().get("ApiResponses");
455455
if (apiResponses != null) {
456456
/** ApiResponses annotation: */
457457
Set<Integer> codes = new HashSet<>();
@@ -572,7 +572,7 @@ private String description(RouteMethod route, String summary) {
572572
}
573573

574574
private String summary(RouteMethod route) {
575-
String summary = stringAttribute(route, "apiOperation");
575+
String summary = stringAttribute(route, "ApiOperation");
576576
if (summary == null) {
577577
return route.description().map(description -> {
578578
int dot = description.indexOf('.');

0 commit comments

Comments
 (0)