european-commission-empl / european-digital-credentials

European Union Public License 1.2
5 stars 3 forks source link

Test failure in eu.europa.ec.empl.edci.issuer.service.WorkBookEuroPassDynamicServiceTest #3

Open SeSodesa opened 3 years ago

SeSodesa commented 3 years ago

Compilation of the project root pom.xml with the command

mvn clean install -e

fails, as the tests in

eu.europa.ec.empl.edci.issuer.service.WorkBookEuroPassDynamicServiceTest

do not pass. The specific error goes as follows:

-------------------------------------------------------------------------------
Test set: eu.europa.ec.empl.edci.issuer.service.WorkBookEuroPassDynamicServiceTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.556 s <<< FAILURE! - in eu.europa.ec.empl.edci.issuer.service.WorkBookEuroPassDynamicServiceTest
eu.europa.ec.empl.edci.issuer.service.WorkBookEuroPassDynamicServiceTest  Time elapsed: 0.556 s  <<< ERROR!
org.mockito.exceptions.base.MockitoException: 
Unable to initialize @Spy annotated field 'xmlUtil'.
Unable to create mock instance of type 'XmlUtil'
Caused by: org.mockito.exceptions.base.MockitoException: Unable to create mock instance of type 'XmlUtil'
Caused by: org.mockito.creation.instance.InstantiationException: 

Unable to create instance of 'XmlUtil$MockitoMock$449244233'.
Please ensure the target class has a 0-arg constructor and executes cleanly.
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException

Replacing the lines

@Spy
private XmlUtil xmlUtil;

with the lines

@Mock
private XmlUtil xmlUtil;

on lines 55--56 of

edci-issuer/edci-issuer-service/src/test/java/eu/europa/ec/empl/edci/issuer/service/WorkBookEuroPassDynamicServiceTest.java ,

as in not tracking the interactions with the class instance during tests, allows the tests to progress further (still without passing, though). Not sure if this would be beneficial or not, but as of now the project can't be compiled without making this replacement.

SeSodesa commented 3 years ago

In seems like this same issue occurs in the file

edci-wallet/edci-wallet-service/src/test/java/integration/eu/europa/ec/empl/edci/wallet/service/VerifiablePresentationITest.java

on lines 43--44. Again, no spy object can be constructed for a class. It has to be an instance of said class.

Esayos commented 2 years ago

Hello @SeSodesa, for the next version, tests will be refactored and this will be corrected. In the meantime please disable the tests.