cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.NullPointerException when sorting project properties

Highlighted
Contributor

java.lang.NullPointerException when sorting project properties

I have 146 project properties that I would like to sort. I have found this post. I modified the code a bit to sort project properties. See below: 

def obj = testRunner.testCase.testSuite.project
log.info "Number of Properties: " + obj.getPropertyCount();

def propList = []; // Arraylist to store properties
obj.getPropertyList().each { prop -> // For all Project (custom) properties
	propList.add(prop.name);  // Add it to the arraylist
}
def sortedList = propList.sort(); // Sort the array list
def index = 0
sortedList.each { name -> 	// Loop the sorted ArrayList
	log.info index + " - " + name + " - " + obj.getPropertyValue(name)
	obj.moveProperty(name, index); // Get Project (custom) property by name an move it to sorted position
	index++
}

I randomly get "java.lang.NullPointerException" when running the code at red statement above. I does however sort 4 to 10 properties before I get the error. So each time I re-run the code I get a bit further before I get error message. So I managed to get the properties sorted. 

But why am I getting this error?

 

Thanks in advance!

4 REPLIES 4
Highlighted
Moderator

Community, we need your help! Smiley Happy

@nmrao@HimanshuTayal@richie@Radford@TanyaGorbunova 


Olga Terentieva
SmartBear Assistant Community Manager

Highlighted
Community Hero

@MadSaid ,

I believe, no custom script is needed to sort any level properties.

Have you not tried the out-of-the-box sort properties ? There is an icon with "up/down arrorw" symbol which does the same. Isn't what you want?



Regards,
Rao.
Highlighted

That only works in that specific screen (project properties screen). Take for example the property transfer test step: you cannot sort the target properties there. I have plus 150 porperties that I cannot sort in this screen. That is the reason I want to sort the project properties. Then they are also sorted in property transfer test step.

Community Manager

Hi @MadSaid,

 

Could you please update to the latest ReadyAPI version and check if you still get the exception? This issue might be fixed there. You can download the installation file here: https://support.smartbear.com/downloads/readyapi/

 

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get a full Raw JMS request

Participate!

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors