im working in a spring boot projet where i create an api that return a file from classpath and all works fine , this is my api :
@Value(value = "classpath:pdf/notice_file.pdf")
private Resource myPdfResource;
@GetMapping("/getLocalDocument/{typeDoc}")
public ResponseEntity<byte[]> getLocalDocument(@PathVariable String typeDoc)
{
    byte[] contents = new byte[0];
    HttpStatus status = HttpStatus.OK;
    HttpHeaders headers = new HttpHeaders();
    final InputStream in;
    String filename="";
    try {
        headers.setContentType(MediaType.APPLICATION_PDF);
        if ("NOTICE".eqauls(typeDoc)) {
            in = myPdfResource.getInputStream();
            contents = IOUtils.toByteArray(in);
            filename = "notice_1.pdf";
        }
        headers.setContentDispositionFormData(filename, filename);
        headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
        return new ResponseEntity<>(contents, headers, status);
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
all the tests methods are ok but i'm getting an error with the method getLocalDocumentTest , and this is my unit test code :
@RunWith(SpringRunner.class)
@PrepareForTest(IOUtils.class)
public class ApiTest{
    @Mock
    private Resource myPdfResource;
    @InjectMocks
    private Api api;
    private MockMvc mockMvc;
    @Before
    public void setUp() throws Exception {
        mockMvc = MockMvcBuilders.standaloneSetup(api).build();
    }
    @Test
    public void getLocalDocumentTest() throws Exception {
        String typeDoc= "NOTICE";
        byte[] contents = new byte[0];
         InputStream stubInputStream = IOUtils.toInputStream("some test data for my input stream", "UTF-8");;
        String URI = "/v1/getLocalDocument/"+typeDoc;
        when(myPdfResource.getInputStream()).thenReturn(stubInputStream);
        PowerMockito.mockStatic(IOUtils.class);
        PowerMockito.when(IOUtils.toByteArray(any(InputStream.class))).thenReturn(contents);
        RequestBuilder requestBuilder = MockMvcRequestBuilders.get(URI);
        MvcResult mvcResult = mockMvc.perform(requestBuilder).andReturn();
        MockHttpServletResponse response = mvcResult.getResponse();
        assertEquals(HttpStatus.OK.value(), response.getStatus());
    }
}
when i run the test i'm getting the following error :
You cannot use argument matchers outside of verification or stubbing.
Examples of correct usage of argument matchers:
    when(mock.get(anyInt())).thenReturn(null);
    doThrow(new RuntimeException()).when(mock).someVoidMethod(anyObject());
    verify(mock).someMethod(contains("foo"))
Also, this error might show up because you use argument matchers with methods that cannot be mocked.
Following methods *cannot* be stubbed/verified: final/private/equals()/hashCode().
do you have any idea please why i'm getting this error , im new in mockito framework
Thanks.
 
    