@Test public void testDeleteCertification() throws CredentialAlreadyExistsException { profile.addCredential(certification); action.setProfile(profile); action.setCertification(certification); assertEquals(1, profile.getCredentials().size()); action.deleteCertification(); assertEquals(0, profile.getCredentials().size()); verify(mockProfileService).save(profile, FormTypeEnum.CV); }
@Test public void testSaveCertification_InvalidDates() throws Exception { action.setCertification(certification); action.setEffectiveDate("12/2010"); action.setExpirationDate("11/2010"); assertEquals(ActionSupport.INPUT, action.saveCertification()); verifyZeroInteractions(mockProfileService); assertEquals( action.getText("error.expiration.date.before.effective"), action.getFieldErrors().get("expirationDate").get(0)); }
@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()); }
@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()); }