@Test public void testCertificationGetters() { Certification credential = CredentialFactory.getInstance().createCertification(); credential.getCertificationType().setId(1L); action.setCredential(new Degree()); assertNull(action.getCertification()); action.setCertification(new Certification()); when(mockDataService.getPersistentObject(CertificationType.class, null)).thenReturn(null); when(mockDataService.getPersistentObject(CertificationType.class, 1L)) .thenReturn(credential.getCertificationType()); action.setCertificationTypeId(null); assertNull(action.getCertificationTypeId()); action.setCertificationTypeId(1L); assertEquals(Long.valueOf(1L), action.getCertificationTypeId()); }
@Test public void testSaveCertification() throws Exception { when(mockDataService.getPersistentObject(eq(CertificationType.class), anyLong())) .thenReturn(CredentialFactory.getInstance().createCertification().getCertificationType()); action.setCertification(certification); action.setEffectiveDate("11/2010"); action.setExpirationDate("12/2010"); action.setCertificationTypeId(1234L); assertEquals(FirebirdUIConstants.RETURN_CLOSE_DIALOG, action.saveCertification()); verify(mockProfileService).saveCredential(profile, certification, FormTypeEnum.CV); }
@Test public void testSaveCertification_ValidationError() throws Exception { when(mockDataService.getPersistentObject(eq(CertificationType.class), anyLong())) .thenReturn(CredentialFactory.getInstance().createCertification().getCertificationType()); doThrow(ValidationExceptionFactory.getInstance().create()) .when(mockProfileService) .saveCredential(profile, certification, FormTypeEnum.CV); action.setCertification(certification); action.setEffectiveDate("12/2010"); action.setCertificationTypeId(1234L); assertEquals(ActionSupport.INPUT, action.saveCertification()); }