package at.gv.egovernment.moa.id.auth.modules.ehvd.test.utils; import static org.junit.Assert.assertEquals; import org.apache.commons.lang3.RandomStringUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import at.gv.egiz.eaaf.core.api.IStatusMessenger; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({"/test_ehvd_service_messager_auth.beans.xml"}) public class MoaStatusMessagerTest { @Autowired IStatusMessenger messager; @Test public void checkErrorCodeMapper() { assertEquals("default errorcode", "9199", messager.getResponseErrorCode(new NullPointerException())); assertEquals("new errorCode file", "aabbccdd", messager.mapInternalErrorToExternalError("test.01")); assertEquals("new errorCode file", "zzzyyyxxx", messager.mapInternalErrorToExternalError("test.02")); assertEquals("existing errorCode file", "4401", messager.mapInternalErrorToExternalError("auth.34")); assertEquals("existing errorCode file", "1101", messager.mapInternalErrorToExternalError("parser.07")); } @Test public void checkErrorMessages() { assertEquals("new error msg", "Für den abgefragtem GDA liegt keine Berechtigung vor", messager.getMessage("ehvd.00", null)); assertEquals("new error msg", "Allgemeiner Fehler bei der Abfrage des EHVD Service", messager.getMessage("ehvd.99", null)); assertEquals("existing error msg", "Zertifikat konnte nicht ausgelesen werden.", messager.getMessage("auth.14", null)); assertEquals("existing error msg", "\"Issuer\" im AUTH-Block nicht vorhanden.", messager.getMessage("validator.32", null)); } }