I have this method
@Secured(value = { "fiscal", "sistemas" })
public void copiarFichero(Integer idFichero, String nombreFichero) {
logger.debug("copiarFichero: Se copia el fichero: " + nombreFichero);
try {
gestorDocumental.copiarDocumento(idFichero, nombreFichero);
} catch (ServicioWebException e) {
logger.error("copiarFichero: Error " + e.getMessage()
+ e.getCause());
}
}
I cover the try part but the catch part I can't I don't know how to modify the test to make a null pointer
@Test
public void copiarFichero() {
try {
Mockito.doAnswer(new Answer<Void>() {
public Void answer(InvocationOnMock invocation)
throws Throwable {
return null;
}
}).when(gestorDocumental)
.copiarDocumento(Mockito.anyInt(), Mockito.anyString());
} catch (ServicioWebException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
instance.copiarFichero(1, "asf");
}