Search in sources :

Example 21 with ExpectedException

use of org.springframework.test.annotation.ExpectedException in project gocd by gocd.

the class AutoTriggerDependencyResolutionTest method shouldContinueBackTrackingFromItsLastKnownPositionAndNotFromTheBeginning.

@Test(timeout = 10 * 1000)
@ExpectedException(NoCompatibleUpstreamRevisionsException.class)
public void shouldContinueBackTrackingFromItsLastKnownPositionAndNotFromTheBeginning() {
    int i = 1;
    GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder1");
    String[] git_revs1 = { "g11", "g12", "g13" };
    u.checkinInOrder(git1, u.d(i++), git_revs1);
    GitMaterial git2 = u.wf(new GitMaterial("git2"), "folder2");
    String[] git_revs2 = { "g21", "g22", "g23" };
    u.checkinInOrder(git2, u.d(i++), git_revs2);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(git1), u.m(git2));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(git1), u.m(git2));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p1), u.m(p2));
    CruiseConfig cruiseConfig = goConfigDao.load();
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g11", "g21");
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g12", "g21");
    String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g11", "g23");
    MaterialRevisions given = u.mrs(u.mr(p1, true, p1_1), u.mr(p2, true, p2_2));
    assertThat(getRevisionsBasedOnDependencies(p3, cruiseConfig, given), is(given));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 22 with ExpectedException

use of org.springframework.test.annotation.ExpectedException in project gocd by gocd.

the class UserSqlMapDaoIntegrationTest method shouldThrowExceptionWhenUserIsNotFound.

@Test
@ExpectedException(UserNotFoundException.class)
public void shouldThrowExceptionWhenUserIsNotFound() {
    String userName = "invaliduser";
    userDao.deleteUser(userName);
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 23 with ExpectedException

use of org.springframework.test.annotation.ExpectedException in project head by mifos.

the class LoanBOTest method testInvalidConnectionForSave.

@Test
@ExpectedException(value = AccountException.class)
public void testInvalidConnectionForSave() throws PersistenceException {
    final LegacyAccountDao legacyAccountDao = mock(LegacyAccountDao.class);
    LoanBO loanBO = new LoanBO() {

        @Override
        public LegacyAccountDao getlegacyAccountDao() {
            return legacyAccountDao;
        }
    };
    try {
        when(legacyAccountDao.createOrUpdate(loanBO)).thenThrow(new PersistenceException("some exception"));
        loanBO.update();
        junit.framework.Assert.fail("should fail because of invalid session");
    } catch (AccountException e) {
    }
}
Also used : AccountException(org.mifos.accounts.exceptions.AccountException) LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 24 with ExpectedException

use of org.springframework.test.annotation.ExpectedException in project head by mifos.

the class LoanPrdBusinessServiceTest method testInvalidConnectionThrowsExceptionInGetAllLoanOfferings.

@Test
@ExpectedException(value = ServiceException.class)
public void testInvalidConnectionThrowsExceptionInGetAllLoanOfferings() throws PersistenceException {
    try {
        when(loanPrdPersistence.getAllLoanOfferings(localeId)).thenThrow(new PersistenceException("some exception"));
        loanPrdBusinessService.getAllLoanOfferings(localeId);
        Assert.fail("should fail because of invalid session");
    } catch (ServiceException e) {
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 25 with ExpectedException

use of org.springframework.test.annotation.ExpectedException in project head by mifos.

the class LoanPrdBusinessServiceTest method testInvalidConnectionThrowsExceptionInGetLoanOffering.

@Test
@ExpectedException(value = ServiceException.class)
public void testInvalidConnectionThrowsExceptionInGetLoanOffering() throws PersistenceException {
    try {
        when(loanPrdPersistence.getLoanOffering(new Short("112"))).thenThrow(new PersistenceException("some exception"));
        loanPrdBusinessService.getLoanOffering(new Short("112"));
        Assert.fail("should fail because of invalid session");
    } catch (ServiceException e) {
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Aggregations

Test (org.junit.Test)36 ExpectedException (org.springframework.test.annotation.ExpectedException)36 PersistenceException (org.mifos.framework.exceptions.PersistenceException)32 ServiceException (org.mifos.framework.exceptions.ServiceException)29 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)2 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)2 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 AccountException (org.mifos.accounts.exceptions.AccountException)1 FeeException (org.mifos.accounts.fees.exceptions.FeeException)1 LegacyAccountDao (org.mifos.accounts.persistence.LegacyAccountDao)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 OfficeBO (org.mifos.customers.office.business.OfficeBO)1 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)1 UserContext (org.mifos.security.util.UserContext)1