use of org.springframework.transaction.annotation.Transactional in project head by mifos.
the class QuestionGroupInstanceDaoIntegrationTest method shouldPersistQuestionGroupInstance.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldPersistQuestionGroupInstance() throws SystemException {
String title = "QG1" + currentTimeMillis();
List<SectionDetail> details = asList(getSection("S1"), getSection("S2"));
QuestionGroupDetail questionGroupDetail = defineQuestionGroup(title, "Create", "Client", details, false);
QuestionGroup questionGroup = questionGroupDao.getDetails(questionGroupDetail.getId());
QuestionGroupInstance questionGroupInstance = getQuestionGroupInstance(1, questionGroup, 101, "Foo Bar1", "Foo Bar2");
questionGroupInstanceDao.saveOrUpdateAll(asList(questionGroupInstance));
QuestionGroupInstance groupInstance = questionGroupInstanceDao.getDetails(questionGroupInstance.getId());
assertThat(groupInstance, is(notNullValue()));
assertThat(groupInstance.getQuestionGroupResponses(), is(notNullValue()));
assertThat(groupInstance.getQuestionGroupResponses().size(), is(2));
assertThat(groupInstance.getQuestionGroupResponses().get(0).getSectionQuestion(), is(notNullValue()));
assertThat(groupInstance.getQuestionGroupResponses().get(0).getSectionQuestion(), is(questionGroup.getSections().get(0).getQuestions().get(0)));
assertThat(groupInstance.getQuestionGroupResponses().get(0).getResponse(), is("Foo Bar1"));
assertThat(groupInstance.getQuestionGroupResponses().get(1).getSectionQuestion(), is(notNullValue()));
assertThat(groupInstance.getQuestionGroupResponses().get(1).getSectionQuestion(), is(questionGroup.getSections().get(1).getQuestions().get(0)));
assertThat(groupInstance.getQuestionGroupResponses().get(1).getResponse(), is("Foo Bar2"));
}
use of org.springframework.transaction.annotation.Transactional in project head by mifos.
the class QuestionGroupInstanceDaoIntegrationTest method shouldGetLatestQuestionGroupInstancesBasedOnQuestionGroupAndEntity.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldGetLatestQuestionGroupInstancesBasedOnQuestionGroupAndEntity() {
String title = "QG1" + currentTimeMillis();
List<SectionDetail> details = asList(getSection("S1"), getSection("S2"));
QuestionGroupDetail questionGroupDetail = defineQuestionGroup(title, "Create", "Client", details, false);
QuestionGroup questionGroup = questionGroupDao.getDetails(questionGroupDetail.getId());
QuestionGroupInstance instance1 = getQuestionGroupInstance(1, questionGroup, 101, "Foo Bar1", "Foo Bar2");
QuestionGroupInstance instance2 = getQuestionGroupInstance(2, questionGroup, 101, "Hello World1", "Hello World2");
questionGroupInstanceDao.saveOrUpdateAll(asList(instance1, instance2));
List<QuestionGroupInstance> instances = questionGroupInstanceDao.retrieveLatestQuestionGroupInstanceByQuestionGroupAndEntity(101, questionGroupDetail.getId());
assertThat(instances, is(notNullValue()));
assertThat(instances.size(), is(1));
QuestionGroupInstance qGInst = instances.get(0);
assertThat(qGInst.getVersionNum(), is(2));
assertThat(qGInst.getEntityId(), is(101));
assertThat(qGInst.getQuestionGroup().getId(), is(questionGroupDetail.getId()));
List<QuestionGroupResponse> qGResponses = qGInst.getQuestionGroupResponses();
assertThat(qGResponses, is(notNullValue()));
assertThat(qGResponses.size(), is(2));
assertThat(qGResponses.get(0).getResponse(), is("Hello World1"));
assertThat(qGResponses.get(1).getResponse(), is("Hello World2"));
}
use of org.springframework.transaction.annotation.Transactional in project head by mifos.
the class QuestionnaireValidatorIntegrationTest method shouldCheckForInValidEventSource.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldCheckForInValidEventSource() {
EventSourceDto eventSourceDto = new EventSourceDto("Disburse", "Client", "Disburse Client");
try {
questionnaireValidator.validateForEventSource(eventSourceDto);
fail("Should have raised a validation error for invalid event");
} catch (SystemException e) {
assertThat(e.getKey(), is(QuestionnaireConstants.INVALID_EVENT_SOURCE));
}
}
use of org.springframework.transaction.annotation.Transactional in project head by mifos.
the class QuestionnaireValidatorIntegrationTest method shouldCheckForValidEventSource.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldCheckForValidEventSource() {
EventSourceDto eventSourceDto = new EventSourceDto("Create", "Client", "Create Client");
try {
questionnaireValidator.validateForEventSource(eventSourceDto);
eventSourceDto = new EventSourceDto("View", "Client", "View Client");
questionnaireValidator.validateForEventSource(eventSourceDto);
eventSourceDto = new EventSourceDto("Create", "Loan", "Create Loan");
questionnaireValidator.validateForEventSource(eventSourceDto);
} catch (SystemException e) {
fail("Should not have raised a validation error for this event");
}
}
use of org.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.
the class SnmpAssetProvisioningAdapterFullIT method testAddNodeDirectly.
@Test
// Relies on records created in @Before so we need a fresh database
@JUnitTemporaryDatabase
@Transactional
public void testAddNodeDirectly() throws InterruptedException {
OnmsNode node = m_nodeDao.get(NODE_ID);
assertNotNull(node);
int firstNodeId = node.getId();
m_adapter.doAddNode(firstNodeId);
node = m_nodeDao.get(firstNodeId);
assertNotNull(node);
assertNotNull("AssetRecord comment is null", node.getAssetRecord().getComment());
assertEquals(EXPECTED_COMMENT_FIELD, node.getAssetRecord().getComment());
}
Aggregations