use of org.apache.tapestry5.plastic.MethodDescription in project tapestry-5 by apache.
the class ComponentEventImplTest method store_result_and_continue.
@Test
public void store_result_and_continue() {
Object result = new Object();
String methodDescription = "foo.Bar.baz()";
ComponentEventCallback handler = mockComponentEventHandler();
Logger logger = mockLogger();
ComponentPageElementResources resources = mockResources();
ComponentModel model = mockComponentModel();
train_isDebugEnabled(logger, true);
logger.debug(eq(TapestryMarkers.EVENT_HANDLER_METHOD), isA(String.class));
train_handleResult(handler, result, false);
replay();
ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, resources, false, model, logger);
event.setMethodDescription(methodDescription);
assertFalse(event.storeResult(result));
assertFalse(event.isAborted());
verify();
}
use of org.apache.tapestry5.plastic.MethodDescription in project tapestry-5 by apache.
the class DefaultOpenApiDescriptionGenerator method processParameters.
private void processParameters(Method method, final String uri, final String httpMethod, final JSONObject methodDescription) {
JSONArray parametersAsJsonArray = new JSONArray();
for (Parameter parameter : method.getParameters()) {
final JSONObject parameterDescription = new JSONObject();
if (!isIgnored(parameter) && !parameter.isAnnotationPresent(StaticActivationContextValue.class)) {
parameterDescription.put("in", "path");
} else if (parameter.isAnnotationPresent(RequestParameter.class)) {
parameterDescription.put("in", "query");
} else if (parameter.isAnnotationPresent(RequestBody.class)) {
processRequestBody(method, uri, httpMethod, methodDescription, parametersAsJsonArray, parameter);
}
if (!parameterDescription.isEmpty()) {
// Optional<String> parameterName = getValue(method, uri, httpMethod, parameter, "name");
// parameterDescription.put("name", parameterName.orElse(parameter.getName()));
parameterDescription.put("name", getParameterName(parameter));
getValue(method, uri, httpMethod, parameter, "description").ifPresent((v) -> parameterDescription.put("description", v));
typeDescriber.describe(parameterDescription, parameter);
parametersAsJsonArray.add(parameterDescription);
}
}
if (!parametersAsJsonArray.isEmpty()) {
methodDescription.put("parameters", parametersAsJsonArray);
}
}
use of org.apache.tapestry5.plastic.MethodDescription in project tapestry-5 by apache.
the class DefaultOpenApiDescriptionGenerator method processResponses.
private void processResponses(Method method, final String uri, final String httpMethod, final JSONObject methodDescription) {
JSONObject responses = new JSONObject();
JSONObject defaultResponse = new JSONObject();
int statusCode = httpMethod.equals("post") || httpMethod.equals("put") ? HttpServletResponse.SC_CREATED : HttpServletResponse.SC_OK;
putIfNotEmpty(defaultResponse, "description", getValue(method, uri, httpMethod, statusCode));
responses.put(String.valueOf(statusCode), defaultResponse);
String[] produces = getProducedMediaTypes(method);
if (produces != null && produces.length > 0) {
JSONObject contentDescription = new JSONObject();
for (String mediaType : produces) {
JSONObject responseTypeDescription = new JSONObject();
typeDescriber.describeReturnType(responseTypeDescription, method);
contentDescription.put(mediaType, responseTypeDescription);
}
defaultResponse.put("content", contentDescription);
}
methodDescription.put("responses", responses);
}
use of org.apache.tapestry5.plastic.MethodDescription in project tapestry-5 by apache.
the class HeartbeatDeferredWorkerTest method testFailure.
private void testFailure(MethodDescription description, String messageFragment) {
PlasticMethod method = newMock(PlasticMethod.class);
boolean isVoid = description.returnType.equals("void");
expect(method.isVoid()).andReturn(isVoid);
if (isVoid) {
expect(method.getDescription()).andReturn(description).atLeastOnce();
}
expect(method.getMethodIdentifier()).andReturn("<MethodId>");
replay();
try {
worker.deferMethodInvocations(method);
unreachable();
} catch (RuntimeException ex) {
assertMessageContains(ex, messageFragment);
}
verify();
}
use of org.apache.tapestry5.plastic.MethodDescription in project tapestry-5 by apache.
the class TapestryModule method add.
private static void add(OrderedConfiguration<ComponentClassTransformWorker2> configuration, Class<? extends Annotation> annotationClass, MethodDescription description) {
String name = TapestryInternalUtils.lastTerm(annotationClass.getName());
ComponentClassTransformWorker2 worker = new PageLifecycleAnnotationWorker(annotationClass, description, name);
configuration.add(name, worker);
}
Aggregations