Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Issue while writing Junit for Bitbucket plugin custom java class

HI all

I am facing issue while writing Junit for Atlassian – bitbucket plugins custom class.

Can some help on this?



I am developing bitbucket plugin which store bitbucket file extra details in Bitbucket data-base [Embedded on bitbucket-server].

I have created one custom java class which is mapped with Bitbucket database table. sample code:

public interface FileDetails extends<Long>{

//getters and setter



For fetch Bitbucket File-Detail I am using custom service class which fetch file-detail from bitbucket-database.


Sample Code of server class:

                public FileDetails getFileDetails(String fileName) {

                                       return ao.executeInTransaction(new TransactionCallback< FileDetails >()


                                                public FileDetails doInTransaction() {

                                                // getting file details from bitbucket Database

                                                                final FileDetails[] fileDetails =ao.find(FileDetails.class, GET_FILE_QUERY,fileName);

                                                                //returninig file details

                                                                return fileDetails;




Issue I am facing while writing Junit for service class

Where I am mocking method getFileDetails using Mockito framework.

Pom entry for Junit is:














Sample code for Junit class where mocking file Object:


FileDetails fileDetails =new FileDetails();


Mockito.when(Customervice.getFileDetails( fileName)).thenReturn(fileDetails);


  • Every time when I run the Junit

Getting null value of  “fileDetails” object

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Bitbucket

How do you use the Bitbucket-Jira integration? How does it help your team?

Hey everyone, over the past year, we've added several new features on how you can use Bitbucket and Jira together. We'd love to know how you'll are using the integration and how it's helping your t...

97 views 0 2
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you