@Test public void testGetQuestionsByCompanyWithOnlyCompanyName() { Company company = new Company(); company.setName(this.company.getName()); try { Question[] questions = service.getQuestionsByCompany(company); assert questions != null; assert questions.length == 2; } catch (TapWisdomException e) { e.printStackTrace(); assert false; } }
@Test public void testGetQuestionsByCompanyWithTags() { Company company = new Company(); company.setId(this.company.getId()); company.setIndustry(this.company.getIndustry()); try { Map<String, List<Question>> questions = service.getQuestionsByCompanyWithTags(company); assert questions != null; assert questions.get("technology").size() == 1; assert questions.get("culture").size() == 2; } catch (TapWisdomException e) { assert false; } }
@Test public void testUpdateQuestion() { Question question = questions.get(0); Question newQuestion = new Question(); String newQStr = "What is the culture like?"; newQuestion.setId(question.getId()); newQuestion.setContent(newQStr); try { boolean updated = service.updateQuestion(newQuestion); assert updated == true; assert ((String) newQuestion.getContent()).equals(newQStr); } catch (TapWisdomException e) { e.printStackTrace(); assert false; } }
@Test(expected = TapWisdomException.class) public void testGetQuestionsByCompanyWithNonExisting() throws TapWisdomException { Company company = new Company(); company.setId("company2"); Question[] questions = service.getQuestionsByCompany(company); }
@Test(expected = TapWisdomException.class) public void testGetQuestionsByCompanyWithInvalidCompany() throws TapWisdomException { Company company = new Company(); company.setName("invalidName"); service.getQuestionsByCompany(company); }