How to register a ContraintValidator with MockMvc? - spring

I know this was asked before, but that was never really answered satisfactory.
How do you add a ContstraintValidator with MockMvc?
I expected to find something on the StandaloneMockMvcBuilder, as I was able to use it to add an argument resolver, but I don't see anything for it. There is setValidator() but that doesn't support a javax.validation.ContstraintValidator.

Related

Why define TP_ARGS in TRACEPOINT_EVENT_CLASS and in TRACEPOINT_EVENT_INSTANCE both?

I'm currently using LTTng for such performances issues, and I want to use TRACEPOINT_EVENT_CLASS and TRACEPOINT_EVENT_INSTANCE as well.
But I don't understand the 2.10 version's documentation. I wonder why we need to define TP_ARGS in each event instance as well as defining it in the event class.
Because we can't modify TP_FIELDS to change the type of any field, or compose it from many arguments.
The TP_ARGS() portion of a TRACEPOINT_EVENT_INSTANCE is used to validate that each instance matches the TRACEPOINT_EVENT_CLASS. See ust-tracepoint-event.h for more context.
I recommend that you repost your question on our mailing list/irc channel so that we can have an actual discussion regarding this. The maintainer of lttng-ust and lttng-modules, Compudj will surely provide more context and might even be open to the introduction of a new macro allowing event instance declaration without the TP_ARGS() portion.

What is the default advice kind when using <aop:advisor>?

What is the default advice kind when using <aop:advisor>? Is it around or something else? I did not find much information in docs. Any link to more information? Thanks.
Well, as the documentation says here:
The advice itself is represented by a bean, and must implement one of the advice interfaces described in Advice types in Spring.
Thus, it is your own choice which type of advice you want to implement in your advisor. It can be any of
around,
before,
after returning,
throws,
introduction.

How can I manually compile something inside Eclipse?

One way of doing seemed to be to use the java.lang.Compiler
I tried to use the java.lang.Compiler inside Eclipse anddid not understand the Object any parameters for the methods of that class? And putting in a class did not seem to work either.
Compiler.command(any) // what is meant by any? What are valid objects to put there?
Compiler.compileClass(clazz) // Nothing happens when I out a class in there?
Compiler.compileClasses(string) // hm?
How to can I print a hello message with a Compiler inside Eclipse...?
Reading the documentation is a very important skill you need to learn.
Whenever you come across a class or a method that you don't know the functionality of, simply look at the documentation first.
Here is the docs for java.lang.Compiler: https://docs.oracle.com/javase/7/docs/api/java/lang/Compiler.html
This is the first sentence of the document:
The Compiler class is provided to support Java-to-native-code compilers and related services. By design, the Compiler class does nothing; it serves as a placeholder for a JIT compiler implementation.
So, the answer to your question is, it does nothing. According to the documentation, it does nothing. It is used to start up the Java compiler when the JVM starts. You are not meant to use this.

Hint or infer the return type for RSpec let() implementing FactoryGirl create()

Using RubyMine, in an rspec test, is there a way to let RubyMine know the type of the created object (for auto-completion and 'cannot find ' warning suppression?
eg:
# #yieldreturn [Tibbees::Tibbee]
let!(:tibbee) {
create(:tibbee,
canonical_vendible: article_vendible,
owner: tibbee_user)
}
RubyMine doesn't seem to recognise #yieldreturn (and I'm not sure if that's correct anyhow) and I've had no luck with #type and #return.
The
let!(:tibbee) { create(...) || Tibbees::Tibbee.new }
cludge works, but yuk. Any advice greatly appreciated. Perhaps there's even a way to let the factories take care of it, but that seems 'too deep' an abstraction to be likely to be picked up by RubyMine?
Not an immediate solution, but:
While google on this, I came across https://github.com/JetBrains/ruby-type-inference which holds great promise for the future, that is probably relevant to anyone with an interest in this question.
From the README:
ruby-type-inference project is a completely new approach to tackle the problems Ruby dynamic nature by providing more reliable symbol resolution and type inference.
In answer to some questions I asked them:
We are going to make the plugin working and publicly available with 2017.3 release though it will definitely be in "beta" since several problems are yet to be solved even on the theoretical side. For everything to work real properly we have to rework our type system on IDE side which is most likely not going to be completed in 2017.
It might be run at the moment, however ... the results are more of experimental value ... [and] it will be difficult to use it on a daily basis.
This is an old request, but updating for future reference with discussion at https://youtrack.jetbrains.com/issue/RUBY-19907:
As of today (RubyMine 2021.2.3, Build #RM-212.5457.52) Rubymine can now introspect the correct type for FactoryBot create within a let, so that:
let(:name) { create(:some_model)} now has the type inferred correct from the factory.
However it would still be useful to be able to annotate a let that can't be introspected (maybe it's not calling FactoryBot).
But the suggestion of #yieldreturn seems wrong - that's for methods that take a block. But it would be nice if you could annotate let(:whatever){} with #return tag. Compare https://rubydoc.info/gems/yard/file/docs/Tags.md#yieldreturn with https://rubydoc.info/gems/yard/file/docs/Tags.md#return

Detect if golang method is internal?

I'm writing a function that iterates over the methods on a given struct and binds the methods to handlers. I would like to skip over internal methods if possible. I'm not sure if this is possible to do so explicitly - I reviewed the documentation for the reflect package and I didn't see a means to detect if a given Value is an internal method. I know I can get the method's name, and then check if it starts with a lowercase character but I'm not sure if there's a kosher way to accomplish this. It's also possible that the internal / public boundary really only exists at compile time anyways, so there really isn't even a way of knowing this beyond the method's name. In either case I'd like to know for sure. Thanks!
The reflect package will not give you unexported methods via Type.Method. Pretty much, if you can see it via reflect, it is already exported.
See https://play.golang.org/p/61qQYO38P0

Resources