@Test public void testDynamicBindOptionalPresent() { Something result = handle.createQuery(SELECT_BY_NAME) .bindByType("name", Optional.of("eric"), new GenericType<Optional<String>>() {}) .mapToBean(Something.class) .findOnly(); assertThat(result).isEqualTo(new Something(1, "eric")); }
@Test public void testDynamicBindOptionalPresent() { Something result = handle.createQuery(SELECT_BY_NAME) .bindByType("name", Optional.of("eric"), new GenericType<Optional<String>>() {}) .mapToBean(Something.class) .findOnly(); assertThat(result).isEqualTo(new Something(1, "eric")); }
@Test public void testDynamicBindOptionalEmpty() { List<Something> result = handle.createQuery(SELECT_BY_NAME) .bindByType("name", Optional.empty(), new GenericType<Optional<String>>() {}) .mapToBean(Something.class) .list(); assertThat(result).containsExactly(new Something(1, "eric"), new Something(2, "brian")); }
@Test public void testDynamicBindOptionalEmpty() { List<Something> result = handle.createQuery(SELECT_BY_NAME) .bindByType("name", Optional.absent(), new GenericType<Optional<String>>() {}) .mapToBean(Something.class) .list(); assertThat(result).containsExactly(new Something(1, "eric"), new Something(2, "brian")); }
@Test public void testDynamicBindOptionalOfUnregisteredCustomType() { exception.expect(UnsupportedOperationException.class); handle.createQuery(SELECT_BY_NAME) .bindByType("name", Optional.of(new Name("eric")), new GenericType<Optional<Name>>() {}) .mapToBean(Something.class) .list(); }
@Test public void testDynamicBindOptionalOfUnregisteredCustomType() { exception.expect(UnsupportedOperationException.class); handle.createQuery(SELECT_BY_NAME) .bindByType("name", Optional.of(new Name("eric")), new GenericType<Optional<Name>>() {}) .mapToBean(Something.class) .list(); }
@Test public void testDynamicBindOptionalOfCustomType() { handle.registerArgument(new NameArgumentFactory()); handle.createQuery(SELECT_BY_NAME) .bindByType("name", Optional.of(new Name("eric")), new GenericType<Optional<Name>>() {}) .mapToBean(Something.class) .list(); }
@Test public void testDynamicBindOptionalOfCustomType() { handle.registerArgument(new NameArgumentFactory()); handle.createQuery(SELECT_BY_NAME) .bindByType("name", Optional.of(new Name("eric")), new GenericType<Optional<Name>>() {}) .mapToBean(Something.class) .list(); }
@Test public void testDynamicBindOptionalPresent() { Something result = handle.createQuery(SELECT_BY_NAME) .bindByType("name", Optional.of("eric"), new GenericType<Optional<String>>() {}) .mapToBean(Something.class) .findOnly(); assertThat(result).isEqualTo(new Something(1, "eric")); }
@Test public void testDynamicBindOptionalEmpty() { List<Something> result = handle.createQuery(SELECT_BY_NAME) .bindByType("name", Optional.absent(), new GenericType<Optional<String>>() {}) .mapToBean(Something.class) .list(); assertThat(result).containsExactly(new Something(1, "eric"), new Something(2, "brian")); }
@Test public void testDynamicBindOptionalOfUnregisteredCustomType() { exception.expect(UnsupportedOperationException.class); handle.createQuery(SELECT_BY_NAME) .bindByType("name", Optional.of(new Name("eric")), new GenericType<Optional<Name>>() {}) .mapToBean(Something.class) .list(); }
@Test public void testDynamicBindOptionalOfCustomType() { handle.registerArgument(new NameArgumentFactory()); handle.createQuery(SELECT_BY_NAME) .bindByType("name", Optional.of(new Name("eric")), new GenericType<Optional<Name>>() {}) .mapToBean(Something.class) .list(); }