Search in sources :

Example 11 with JasperTemplate

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()));
}
Also used : JasperTemplate(org.motechproject.mots.domain.JasperTemplate) Test(org.junit.Test)

Example 12 with JasperTemplate

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;
}
Also used : JasperTemplate(org.motechproject.mots.domain.JasperTemplate)

Example 13 with 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()))));
}
Also used : JasperTemplate(org.motechproject.mots.domain.JasperTemplate) Test(org.junit.Test)

Example 14 with JasperTemplate

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);
}
Also used : JasperTemplate(org.motechproject.mots.domain.JasperTemplate) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 15 with JasperTemplate

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);
}
Also used : JasperTemplate(org.motechproject.mots.domain.JasperTemplate) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

JasperTemplate (org.motechproject.mots.domain.JasperTemplate)18 Test (org.junit.Test)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)7 Matchers.anyString (org.mockito.Matchers.anyString)4 MultipartFile (org.springframework.web.multipart.MultipartFile)4 InputStream (java.io.InputStream)3 JRParameter (net.sf.jasperreports.engine.JRParameter)3 JRPropertiesMap (net.sf.jasperreports.engine.JRPropertiesMap)3 JasperReport (net.sf.jasperreports.engine.JasperReport)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 JRExpression (net.sf.jasperreports.engine.JRExpression)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 UUID (java.util.UUID)1 JasperTemplateParameter (org.motechproject.mots.domain.JasperTemplateParameter)1 EntityNotFoundException (org.motechproject.mots.exception.EntityNotFoundException)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1