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
Published in Bitbucket

Bitbucket Server 7.0 is here!

Hello Community, I’m Anton Genkin, a product manager on the Bitbucket Server and Data Center team and am excited to share that Bitbucket Server 7.0 is now available! It's a platform release, one th...

1,578 views 6 6
Read article

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