Search in sources :

Example 1 with Transactional

use of org.springframework.transaction.annotation.Transactional in project head by mifos.

the class StandardApprovalService method create.

@Transactional(noRollbackFor = RESTCallInterruptException.class)
@Override
public void create(ApprovalMethod method) throws Exception {
    if (!skipCreate) {
        RESTApprovalEntity entity = new RESTApprovalEntity();
        entity.setApprovalMethod(method);
        entity.setState(ApprovalState.WAITING);
        entity.setCreatedBy(getCurrentUserId());
        entity.setCreatedOn(new DateTime());
        approvalDao.create(entity);
        throw new RESTCallInterruptException(entity.getId());
    }
}
Also used : RESTApprovalEntity(org.mifos.rest.approval.domain.RESTApprovalEntity) DateTime(org.joda.time.DateTime) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Transactional

use of org.springframework.transaction.annotation.Transactional in project head by mifos.

the class StandardApprovalService method reject.

@Transactional
@Override
public void reject(Long id) {
    RESTApprovalEntity entity = approvalDao.getDetails(id);
    entity.setApprovedBy(getCurrentUserId());
    entity.setApprovedOn(new DateTime());
    entity.setState(ApprovalState.REJECTED);
    approvalDao.update(entity);
}
Also used : RESTApprovalEntity(org.mifos.rest.approval.domain.RESTApprovalEntity) DateTime(org.joda.time.DateTime) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Transactional

use of org.springframework.transaction.annotation.Transactional in project head by mifos.

the class SectionQuestionDaoIntegrationTest method shouldRetrieveSectionQuestionByQuestionIdSectionId.

@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldRetrieveSectionQuestionByQuestionIdSectionId() {
    String title = "QG1" + currentTimeMillis();
    SectionDetail sectionDetail1 = getSection("S1");
    SectionDetail sectionDetail2 = getSection("S2");
    List<SectionDetail> details = asList(sectionDetail1, sectionDetail2);
    QuestionGroupDetail questionGroupDetail = defineQuestionGroup(title, "Create", "Client", details, false);
    QuestionGroup questionGroup = questionGroupDao.getDetails(questionGroupDetail.getId());
    Integer questionId = questionGroup.getSections().get(1).getQuestions().get(1).getQuestion().getQuestionId();
    Integer sectionId = questionGroup.getSections().get(1).getId();
    List<SectionQuestion> sectionQuestions = sectionQuestionDao.retrieveFromQuestionIdSectionId(sectionId, questionId);
    assertThat(sectionQuestions, is(notNullValue()));
    assertThat(sectionQuestions.size(), is(1));
    assertThat(sectionQuestions.get(0).getQuestionText(), is(sectionDetail2.getQuestionDetail(1).getText()));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion) QuestionGroup(org.mifos.platform.questionnaire.domain.QuestionGroup) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Transactional

use of org.springframework.transaction.annotation.Transactional in project head by mifos.

the class QuestionnaireServiceIntegrationTest method shouldDefineSingleSelectQuestion.

@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldDefineSingleSelectQuestion() throws SystemException {
    String questionTitle = TITLE + currentTimeMillis();
    QuestionDetail questionDetail = defineQuestion(questionTitle, QuestionType.SINGLE_SELECT, asList("choice1", "choice2"));
    assertNotNull(questionDetail);
    Integer questionId = questionDetail.getId();
    assertNotNull(questionId);
    QuestionEntity questionEntity = questionDao.getDetails(questionId);
    assertNotNull(questionEntity);
    Assert.assertEquals(questionTitle, questionEntity.getQuestionText());
    Assert.assertEquals(AnswerType.SINGLESELECT, questionEntity.getAnswerTypeAsEnum());
    assertThat(questionEntity.getChoices(), new QuestionChoicesMatcher(asList(new QuestionChoiceEntity("choice1"), new QuestionChoiceEntity("choice2"))));
}
Also used : QuestionChoiceEntity(org.mifos.platform.questionnaire.domain.QuestionChoiceEntity) QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) QuestionChoicesMatcher(org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Transactional

use of org.springframework.transaction.annotation.Transactional in project head by mifos.

the class QuestionnaireServiceIntegrationTest method shouldSaveQuestionGroupFromDto.

@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldSaveQuestionGroupFromDto() {
    String ques1Title = "Ques1" + currentTimeMillis();
    String ques2Title = "Ques2" + currentTimeMillis();
    String qgTitle = "QG1" + currentTimeMillis();
    createSingleSelectQuestion(ques2Title);
    QuestionDto question1 = new QuestionDtoBuilder().withText(ques1Title).withMandatory(true).withType(QuestionType.FREETEXT).withOrder(1).build();
    ChoiceDto choice1 = new ChoiceDetailBuilder().withValue("Ch1").withOrder(1).build();
    ChoiceDto choice2 = new ChoiceDetailBuilder().withValue("Ch2").withOrder(2).build();
    ChoiceDto choice3 = new ChoiceDetailBuilder().withValue("Ch3").withOrder(3).build();
    QuestionDto question2 = new QuestionDtoBuilder().withText(ques2Title).withType(QuestionType.SINGLE_SELECT).addChoices(choice1, choice2, choice3).withOrder(2).build();
    SectionDto section1 = new SectionDtoBuilder().withName("Sec1").withOrder(1).addQuestions(question1, question2).build();
    QuestionGroupDto questionGroupDto = new QuestionGroupDtoBuilder().withTitle(qgTitle).withEventSource("Create", "Client").addSections(section1).build();
    Integer questionGroupId = questionnaireService.defineQuestionGroup(questionGroupDto);
    assertQuestionGroup(questionGroupDao.getDetails(questionGroupId), qgTitle, ques1Title, ques2Title);
}
Also used : SectionDtoBuilder(org.mifos.platform.questionnaire.builders.SectionDtoBuilder) QuestionDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionDtoBuilder) SectionDto(org.mifos.platform.questionnaire.service.dtos.SectionDto) QuestionGroupDto(org.mifos.platform.questionnaire.service.dtos.QuestionGroupDto) QuestionDto(org.mifos.platform.questionnaire.service.dtos.QuestionDto) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) ChoiceDetailBuilder(org.mifos.platform.questionnaire.builders.ChoiceDetailBuilder) QuestionGroupDtoBuilder(org.mifos.platform.questionnaire.builders.QuestionGroupDtoBuilder) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Transactional (org.springframework.transaction.annotation.Transactional)4561 Test (org.junit.Test)1387 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)724 DAOException (com.tomasio.projects.trainning.exception.DAOException)385 CoreException (com.tomasio.projects.trainning.exeption.CoreException)372 ArrayList (java.util.ArrayList)324 Date (java.util.Date)252 Query (javax.persistence.Query)218 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)213 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)211 WithMockUser (org.springframework.security.test.context.support.WithMockUser)204 HashMap (java.util.HashMap)187 List (java.util.List)163 User (io.github.jhipster.sample.domain.User)150 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)135 HashSet (java.util.HashSet)135 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)132 UUID (java.util.UUID)131 Rollback (org.springframework.test.annotation.Rollback)109 ParseException (java.text.ParseException)108