use of org.motechproject.mots.domain.JasperTemplate in project mots by motech-implementations.
the class JasperTemplateRepositoryIntegrationTest method shouldFindTemplateByName.
@Test
public void shouldFindTemplateByName() {
// given
JasperTemplate entity = generateInstance();
jasperTemplateRepository.save(entity);
// when
JasperTemplate found = jasperTemplateRepository.findByName(entity.getName());
// then
assertThat(found.getName(), is(entity.getName()));
}
use of org.motechproject.mots.domain.JasperTemplate in project mots by motech-implementations.
the class JasperTemplateRepositoryIntegrationTest method generateInstance.
@Override
protected JasperTemplate generateInstance() {
JasperTemplate jasperTemplate = new JasperTemplate();
jasperTemplate.setName(NAME + getNextInstanceNumber());
return jasperTemplate;
}
use of org.motechproject.mots.domain.JasperTemplate in project mots by motech-implementations.
the class JasperTemplateRepositoryIntegrationTest method shouldFindByVisibilityFlag.
@Test
public void shouldFindByVisibilityFlag() {
JasperTemplate visibleTemplate = generateInstance();
JasperTemplate hiddenTemplate = generateInstance();
hiddenTemplate.setVisible(false);
jasperTemplateRepository.save(visibleTemplate);
jasperTemplateRepository.save(hiddenTemplate);
assertThat(jasperTemplateRepository.findByVisibleOrderByCreatedDateAsc(true), hasItem(hasProperty("id", is(visibleTemplate.getId()))));
assertThat(jasperTemplateRepository.findByVisibleOrderByCreatedDateAsc(false), hasItem(hasProperty("id", is(hiddenTemplate.getId()))));
}
use of org.motechproject.mots.domain.JasperTemplate in project mots by motech-implementations.
the class JasperTemplateServiceTest method shouldThrowErrorIfFileNotPresent.
@Test
public void shouldThrowErrorIfFileNotPresent() throws Exception {
expectedException.expect(ReportingException.class);
expectedException.expectMessage(ERROR_REPORTING_FILE_MISSING);
jasperTemplateService.validateFileAndInsertTemplate(new JasperTemplate(), null);
}
use of org.motechproject.mots.domain.JasperTemplate in project mots by motech-implementations.
the class JasperTemplateServiceTest method shouldThrowErrorIfTemplateNameAlreadyExists.
@Test
public void shouldThrowErrorIfTemplateNameAlreadyExists() throws Exception {
JasperTemplate jasperTemplate = new JasperTemplate();
jasperTemplate.setName("Name");
expectedException.expect(ReportingException.class);
expectedException.expectMessage(ERROR_REPORTING_TEMPLATE_EXIST);
when(jasperTemplateRepository.findByName(Matchers.anyObject())).thenReturn(jasperTemplate);
jasperTemplateService.validateFileAndInsertTemplate(jasperTemplate, null);
}
Aggregations