Jaxb Annox plugin : Is it possible to change annotation in objectFactory class #XmlElementDecl - jaxb2-maven-plugin

Im getting 2 counts of IllegalAnnotationExceptions The element has more than one mapping. Issue after using an episode file to generate the common classes from 2 xsd files. Now I have 2 objectFactory class with mapping for same element . Im thinking to remove the annotation from one of the factory method as nothing else seems working.

I have solved this issue through another XJC plugin as jaxb2-annotate-plugin didn't have a provision to add or replace annotations in the ObjectFactory class.
I Found any-annotate plugin which does handle this like a charm.
For more details:
https://gitlab.com/virtual-machinist/any-annotate

Related

How to create object from Data class? Kotlin

I have a
data class A(){
fun c(){}
} .
I need to create a fake implementation of it for testing, but it says that class must be open. open modifier is incompatible with data class. Any ways to do it?
To mock final classes update mockito
testCompile 'org.mockito:mockito-core:2.8.9'
and then add a folder in your resources folder called mockito-extensions that includes a text file called org.mockito.plugins.MockMaker. Inside there just add
mock-maker-inline
That should solve your problem

Listener in Testng

I have created a listener class in my project. Now what I have read in web there are two methods to add a listener either to your class or to testng file.
Please check in the folder structure. For now, I m using it like this in my java class but it is giving me error as in image attached:
#Listeners({Test.tes.Utils.ListenerUse.class})
From your screenshots, I understand that your test class HomeTestCases.java resides in the package Test.test.MyHomepageTestCases in src/test/java
You are trying to refer to the listener ListenerToUse.java that resides in the package Test.tes.Utilsin src/main/java.
When you use #Listeners(Test.tes.MyHomepageTestCases.MyHomepageTestCases.ListenerToUse.class)
Here you are basically telling Java to look for the listener class ListenerToUse inside Test.tes.MyHomepageTestCases.MyHomepageTestCases (as a nested class), but that's not the case because ListenerToUse is NOT a embedded class inside MyHomepageTestCases.java.
To fix the problem please do the following:
Change: #Listeners(Test.tes.MyHomepageTestCases.MyHomepageTestCases.ListenerToUse.class)
To: #Listeners(Test.tes.Utils.ListenerToUse.class)
I think the issue is you're mixing the package of your Listener, and the package of the class where you want to add it.
Your code now:
#Listeners(Test.tes.MyHomePageTestCases.MyHomePageTestCases.ListenerUse.class)
Correct package:
#Listeners(Test.tes.Utils.ListenerUse.class)
However, you've named your package "Test", which is (besides breaking Java naming conventions -> https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html) clashing with the TestNG Test class. On your screenshot, I can see that "Test" is grayed out. If you hover with your mouse over it, you'll probably see Eclipse has resolved it as "org.testng.annotations.Test". So you have two options:
Name your packages properly and try again
Expand the imports sections of your HomeTestCases class; manually add:
import Test.tes.Utils.ListenerUse;
and delete the following:
import org.testng.annotations.Test;

IntelliJ IDEA doesn't like a HashMap as delegate

Let's consider the following code:
class MyClass { //Here:IJ says method putAll not implemented
#Delegate
HashMap<String, Integer> map = new HashMap<String, Integer>()
}
hello = new MyClass()
hello.put("x", 1)
println "x=" + hello.get("x")
It works fine when called with Groovy directly on the command line, but IntelliJ IDEA complains about the first line with the following error message:
Method putAll() is not implemented
Any idea why and how to fix it?
I have experienced the same behavior.
What I found was in my IntelliJ project, the class (MyClass) was showing with the .groovy file extension in the Project view. By doing a refactor-->Rename and removing the .groovy extension, the class would then show without the extension in the Project view and the issue was resolved.
The explanation for the issue came when I tried to run the class, which is really a Groovy Script and not just a plain Class. When it compiles, it would encounter an error:
Invalid duplicate class definition, which gave me a hint that I had created what IntelliJ saw as a Class definition, but was really a Groovy script, so IntelliJ, behind the scenes processed the script and created a second, synthetic class for the script.

How to refactor rails methods/classes using Eclipse?

I am in a situation where I need to clean code. I have to do followings
Rename class methods in cotrollers
Rename classes which are extending from other modules and helpers in the controller
Move classes into modules and break classes into sub classes
Rename some models
Apply formating to the code, e.g. alignment, spacing etc
Is there a way to achieve above using Eclipse ?
If not then is there any open source editors/plugins for rafactoring rails application ?
I think this would help you to refactor your code: https://github.com/bpo217/refacto

Aptana Code Assist with custom Class Loader

Is it possible to setup Aptanta to provide code assist for classes loaded with a framework's autoloading class?
For example:
$myInstance = Project_Loader::load('MyClass');
Here, my class would be loaded from a hierarchy as soon as it was found, so if I had these libraries setup:
/library/Library1
/library/Library2
/library/Library3
If MyClass was in Library2, it wound find Library2_MyClass. Aptana works great if I initiate the object using:
$myInstance = new Library2_MyClass();
But is there any way to let Aptana know to load it and use Code Assist/Intellisense based on Project_Loader::load('MyClass')?
Not possible at the moment, as it's very dynamic, and specific to a framework.
What you can do is to add a comment that will hint for the type.
For example:
/* #var $myInstance MyClass*/
$myInstance-> // and you'll get the MyClass code-assist.