Search in sources :

Example 16 with ExpectedException

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

the class RolesPermissionsBusinessServiceTest method testInvalidConnectionInGetRole.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetRole() throws PersistenceException {
    try {
        when(rolesPermissionsPersistence.getRole(id)).thenThrow(new PersistenceException("some exception"));
        service.getRole(id);
        junit.framework.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 17 with ExpectedException

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

the class RolesPermissionsBusinessServiceTest method testInvalidConnectionInGetRoles.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetRoles() throws PersistenceException {
    try {
        when(rolesPermissionsPersistence.getRoles()).thenThrow(new PersistenceException("some exception"));
        service.getRoles();
        junit.framework.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 18 with ExpectedException

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

the class RolesPermissionsBusinessServiceTest method testInvalidConnectionInGetActivities.

@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInGetActivities() throws PersistenceException {
    try {
        when(rolesPermissionsPersistence.getActivities()).thenThrow(new PersistenceException("some exception"));
        service.getActivities();
        junit.framework.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 19 with ExpectedException

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

the class UserSqlMapDaoIntegrationTest method shouldThrowExceptionWhenUserIsNotDisabled.

@Test
@ExpectedException(UserEnabledException.class)
public void shouldThrowExceptionWhenUserIsNotDisabled() {
    String userName = "enabledUser";
    User user = new User(userName);
    userDao.saveOrUpdate(user);
    userDao.deleteUser(userName);
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 20 with ExpectedException

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

the class AutoTriggerDependencyResolutionTest method shouldResolveSimpleDiamondAndThrowLimitException.

@Test
@ExpectedException(MaxBackTrackLimitReachedException.class)
public void shouldResolveSimpleDiamondAndThrowLimitException() {
    int i = 1;
    GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder");
    String[] git_revs1 = { "g11", "g12" };
    u.checkinInOrder(git1, u.d(i++), git_revs1);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(git1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p1));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p1));
    ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p2), u.m(p3));
    CruiseConfig cruiseConfig = goConfigDao.load();
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g11");
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_1);
    String p3_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p3, u.d(i++), p1_1);
    String p1_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g12");
    String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), p1_2);
    MaterialRevisions given = u.mrs(u.mr(p2, true, p2_2), u.mr(p3, false, p3_1));
    MaterialRevisions expected = u.mrs(u.mr(p2, true, p2_1), u.mr(p3, false, p3_1));
    assertThat(getRevisionsBasedOnDependencies(p4, cruiseConfig, given), is(expected));
    systemEnvironment.set(SystemEnvironment.RESOLVE_FANIN_MAX_BACK_TRACK_LIMIT, 1);
    getRevisionsBasedOnDependencies(p4, cruiseConfig, 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)

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