ismail fourati
ismail fourati

Reputation: 1

How to test a Spring method for adding a file to GridFS with JUnit and Mockito?

public String addMaquette(MultipartFile maquette, String keySousRubrique, String projectId, String titrePage) throws IOException {

    DBObject metadata = new BasicDBObject();
    metadata.put("fileSize", maquette.getSize());
    metadata.put("keySousRubrique",keySousRubrique);
    metadata.put("projectId",projectId);
    metadata.put("titrePage",titrePage);

    Object fileID = template.store(maquette.getInputStream(), maquette.getOriginalFilename(), maquette.getContentType(), metadata);

    return fileID.toString();
} 

I'm new to unit testing with JUnit and Mockito, and I'm not sure of the best way to test this method. Can you provide me with some guidance or examples of unit tests for this method?

Thank you in advance!

Upvotes: 0

Views: 40

Answers (0)

Related Questions