use of org.motechproject.mots.domain.JasperTemplateParameter in project mots by motech-implementations.
the class JasperTemplateRepositoryIntegrationTest method shouldBindParametersToTemplateOnSave.
@Test
public void shouldBindParametersToTemplateOnSave() {
// given
JasperTemplateParameter templateParameter = new JasperTemplateParameter();
templateParameter.setName("parameter");
templateParameter.setRequired(true);
JasperTemplate template = generateInstance();
template.setTemplateParameters(Collections.singletonList(templateParameter));
// when
JasperTemplate result = jasperTemplateRepository.save(template);
// then
assertEquals(templateParameter.getTemplate().getId(), result.getId());
}
use of org.motechproject.mots.domain.JasperTemplateParameter in project mots by motech-implementations.
the class JasperTemplateServiceTest method mapRequestParametersToTemplateShouldNotReturnBlankNullOrUndefinedStringValues.
@Test
public void mapRequestParametersToTemplateShouldNotReturnBlankNullOrUndefinedStringValues() {
JasperTemplateParameter param1 = new JasperTemplateParameter();
param1.setTemplate(template);
param1.setName(PARAM1);
JasperTemplateParameter param2 = new JasperTemplateParameter();
param2.setTemplate(template);
param2.setName(PARAM2);
JasperTemplateParameter param3 = new JasperTemplateParameter();
param3.setTemplate(template);
param3.setName(PARAM3);
JasperTemplateParameter param4 = new JasperTemplateParameter();
param4.setTemplate(template);
param4.setName(PARAM4);
Map<String, String[]> requestParameterMap = new HashMap<>();
requestParameterMap.put(PARAM1, new String[] { "" });
requestParameterMap.put(PARAM2, new String[] { " " });
requestParameterMap.put(PARAM3, new String[] { "null" });
requestParameterMap.put(PARAM4, new String[] { "undefined" });
List<JasperTemplateParameter> templateParameterList = Arrays.asList(param1, param2, param3, param4);
when(request.getParameterMap()).thenReturn(requestParameterMap);
when(template.getTemplateParameters()).thenReturn(templateParameterList);
Map<String, Object> resultMap = jasperTemplateService.mapRequestParametersToTemplate(request, template);
assertThat(resultMap.size(), is(0));
}
Aggregations