use of org.springframework.integration.jpa.support.JpaParameter in project spring-integration by spring-projects.
the class JpaExecutorTests method getJpaExecutorForPayloadAsParamSource.
private JpaExecutor getJpaExecutorForPayloadAsParamSource(String query) {
JpaExecutor executor = new JpaExecutor(entityManager);
ExpressionEvaluatingParameterSourceFactory factory = new ExpressionEvaluatingParameterSourceFactory(mock(BeanFactory.class));
factory.setParameters(Collections.singletonList(new JpaParameter("firstName", null, "#this")));
executor.setParameterSourceFactory(factory);
executor.setJpaQuery(query);
executor.setExpectSingleResult(true);
executor.setUsePayloadAsParameterSource(true);
executor.afterPropertiesSet();
return executor;
}
use of org.springframework.integration.jpa.support.JpaParameter in project spring-integration by spring-projects.
the class JpaMessageHandlerParserTests method testJpaMessageHandlerParserWithEntityManagerFactory.
@Test
public void testJpaMessageHandlerParserWithEntityManagerFactory() throws Exception {
setUp("JpaMessageHandlerParserTestsWithEmFactory.xml", getClass());
final AbstractMessageChannel inputChannel = TestUtils.getPropertyValue(this.consumer, "inputChannel", AbstractMessageChannel.class);
assertEquals("target", inputChannel.getComponentName());
final JpaExecutor jpaExecutor = TestUtils.getPropertyValue(this.consumer, "handler.jpaExecutor", JpaExecutor.class);
assertNotNull(jpaExecutor);
final String query = TestUtils.getPropertyValue(jpaExecutor, "jpaQuery", String.class);
assertEquals("select student from Student student", query);
final JpaOperations jpaOperations = TestUtils.getPropertyValue(jpaExecutor, "jpaOperations", JpaOperations.class);
assertNotNull(jpaOperations);
final PersistMode persistMode = TestUtils.getPropertyValue(jpaExecutor, "persistMode", PersistMode.class);
assertEquals(PersistMode.PERSIST, persistMode);
@SuppressWarnings("unchecked") List<JpaParameter> jpaParameters = TestUtils.getPropertyValue(jpaExecutor, "jpaParameters", List.class);
assertNotNull(jpaParameters);
assertTrue(jpaParameters.size() == 3);
}
use of org.springframework.integration.jpa.support.JpaParameter in project spring-integration by spring-projects.
the class ExpressionEvaluatingParameterSourceFactoryTests method testPositionalExpressionParameters.
@Test
public void testPositionalExpressionParameters() {
List<JpaParameter> parameters = new ArrayList<JpaParameter>();
parameters.add(new JpaParameter(null, "#root.toUpperCase()"));
parameters.add(new JpaParameter("bar", null));
factory.setParameters(parameters);
PositionSupportingParameterSource source = factory.createParameterSource("very important");
String position0 = (String) source.getValueByPosition(0);
String position1 = (String) source.getValueByPosition(1);
assertEquals("VERY IMPORTANT", position0);
assertEquals("bar", position1);
}
use of org.springframework.integration.jpa.support.JpaParameter in project spring-integration by spring-projects.
the class ExpressionEvaluatingParameterSourceFactoryTests method testPositionalStaticParameters.
@Test
public void testPositionalStaticParameters() {
List<JpaParameter> parameters = new ArrayList<JpaParameter>();
parameters.add(new JpaParameter("foo", null));
parameters.add(new JpaParameter("bar", null));
factory.setParameters(parameters);
PositionSupportingParameterSource source = factory.createParameterSource("not important");
String position0 = (String) source.getValueByPosition(0);
String position1 = (String) source.getValueByPosition(1);
assertEquals("foo", position0);
assertEquals("bar", position1);
}
use of org.springframework.integration.jpa.support.JpaParameter in project spring-integration by spring-projects.
the class ExpressionEvaluatingParameterSourceFactoryTests method testPositionalExpressionParameters2.
@Test
public void testPositionalExpressionParameters2() {
List<JpaParameter> parameters = new ArrayList<JpaParameter>();
parameters.add(new JpaParameter("bar", null));
parameters.add(new JpaParameter(null, "#root.toUpperCase()"));
factory.setParameters(parameters);
PositionSupportingParameterSource source = factory.createParameterSource("very important");
String position0 = (String) source.getValueByPosition(0);
String position1 = (String) source.getValueByPosition(1);
assertEquals("VERY IMPORTANT", position1);
assertEquals("bar", position0);
}
Aggregations