Sometimes I need to scoff too long to record POJO in my test cases. I was wondering if in any case I could generate mocks from the data of debug variables in Intellij (14)?
As an example, we have a class:
public class MyClass{ private String aVariableWithARatherLongName1; private Double aVariableWithARatherLongName2; private String aVariableWithARatherLongName3; private Long aVariableWithARatherLongName4; private String aVariableWithARatherLongName5; private Boolean aVariableWithARatherLongName6; private String aVariableWithARatherLongName7; private String aVariableWithARatherLongName8; private String aVariableWithARatherLongName9; private String aVariableWithARatherLongName10; private String aVariableWithARatherLongName11; private String aVariableWithARatherLongName12;
And in my view of the debug variable, I will have a list of MyClass variables:
- myClasses = { ArrayList@0 } size = 5 - 0 = { MyClass@1 } - aVariableWithARatherLongName1 = {String} "value 1" - aVariableWithARatherLongName2 = {Double} 2.0 - aVariableWithARatherLongName3 = {String} "value 1" ... - 1 = { MyClass@2 } - aVariableWithARatherLongName1 = {String} "value 2" - aVariableWithARatherLongName2 = {Double} 2.0 - aVariableWithARatherLongName3 = {String} "value 2" ... + 2 = { MyClass@3 } + 3 = { MyClass@4 } + 4 = { MyClass@5 }
And then the plugin or Intellij generate something like below based on the selected language (Groovy in this example):
def mockedResults(){ [ new MyClass(aVariableWithARatherLongName1: 'value 1', aVariableWithARatherLongName2: 2.0, aVariableWithARatherLongName3: 'value 1', ...), new MyClass(aVariableWithARatherLongName1: 'value 2', aVariableWithARatherLongName2: 2.0, aVariableWithARatherLongName3: 'value 2', ...), new MyClass(aVariableWithARatherLongName1: 'value 3', aVariableWithARatherLongName2: 2.0, aVariableWithARatherLongName3: 'value 3', ...), new MyClass(aVariableWithARatherLongName1: 'value 4', aVariableWithARatherLongName2: 2.0, aVariableWithARatherLongName3: 'value 4', ...), new MyClass(aVariableWithARatherLongName1: 'value 5', aVariableWithARatherLongName2: 2.0, aVariableWithARatherLongName3: 'value 5', ...), ] }
Is something like this possible with Intellij (14) or are there any plugins that provide such functions?