@Before
  public void setUp() {
    user = new UsersDTO("userDBTest" + new Date(), "normal" + new Date());
    entityManager.getTransaction().begin();
    user = userResourceFacadeImp.addUser(user);
    entityManager.getTransaction().commit();

    CrisisTypeDTO crisisTypeDTO = crisisTypeResourceFacadeImp.findCrisisTypeByID(1100L);
    CollectionDTO crisisDTO =
        new CollectionDTO(
            "testCrisisName" + new Date(),
            "testCrisisCode" + new Date(),
            false,
            false,
            crisisTypeDTO,
            user,
            user);
    entityManager.getTransaction().begin();
    crisis = crisisResourceFacadeImp.addCrisis(crisisDTO);
    entityManager.getTransaction().commit();
    getDoc();
    entityManager.getTransaction().begin();
    documentDTO = documentResourceFacadeImp.addDocument(documentDTO);
    entityManager.getTransaction().commit();

    taskAnswer =
        new TaskAnswerDTO(documentDTO.getDocumentID(), user.getUserID(), "test_sample_answer");
    taskAnswer.setFromTrustedUser(true);
    Date date = new Date();
    taskAnswer.setTimestamp(date);
  }
 /** Test of getTaskAnswer(documentId, userId) method, of class TaskAnswerResourceFacadeImp. */
 @Test
 public void testinsertTaskAnswerByDocumentIdAndUserId() {
   taskAnswer.setAnswer("test_sample_answer3");
   entityManager.getTransaction().begin();
   taskAnswerResourceFacadeImp.insertTaskAnswer(taskAnswer);
   entityManager.getTransaction().commit();
   TaskAnswerDTO taskAnswer =
       taskAnswerResourceFacadeImp.getTaskAnswer(documentDTO.getDocumentID(), user.getUserID());
   assertEquals(documentDTO.getDocumentID(), taskAnswer.getDocumentID());
 }
 /** Test of getTaskAnswer(documentId) method, of class TaskAnswerResourceFacadeImp. */
 @Test
 public void testGetTaskAnswerByDocumentId() {
   taskAnswer.setAnswer("test_sample_answer2");
   entityManager.getTransaction().begin();
   taskAnswerResourceFacadeImp.insertTaskAnswer(taskAnswer);
   entityManager.getTransaction().commit();
   List<TaskAnswerDTO> taskAnswer =
       taskAnswerResourceFacadeImp.getTaskAnswer(documentDTO.getDocumentID());
   assertTrue(taskAnswer.size() >= 1);
 }
Пример #4
0
 public TaskAnswerDTO toDTO() {
   TaskAnswerDTO dto =
       new TaskAnswerDTO(this.getId().getDocumentId(), this.getId().getUserId(), this.getAnswer());
   dto.setFromTrustedUser(this.isFromTrustedUser());
   return dto;
 }