use of org.hibernate.testing.orm.junit.FailureExpected in project hibernate-orm by hibernate.
the class MutationQueryExampleTests method namedQueryTest.
@Test
@FailureExpected(reason = "Illegal mutation query")
public void namedQueryTest(SessionFactoryScope scope) {
scope.inTransaction((session) -> {
// tag::example-hql-named-mutation-query-query[]
// cannot be validated until execution
Query query = session.createNamedQuery("get_person_by_name");
query.getResultList();
// end::example-hql-named-mutation-query-query[]
});
}
use of org.hibernate.testing.orm.junit.FailureExpected in project hibernate-orm by hibernate.
the class FieldAccessedNestedEmbeddableMetadataTest method testEnumTypeInterpretation.
@Test
@FailureExpected(jiraKey = "HHH-9089")
public void testEnumTypeInterpretation() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
try {
final Metadata metadata = new MetadataSources(ssr).addAnnotatedClass(Customer.class).buildMetadata();
PersistentClass classMetadata = metadata.getEntityBinding(Customer.class.getName());
Property investmentsProperty = classMetadata.getProperty("investments");
Collection investmentsValue = (Collection) investmentsProperty.getValue();
Component investmentMetadata = (Component) investmentsValue.getElement();
Value descriptionValue = investmentMetadata.getProperty("description").getValue();
assertEquals(1, descriptionValue.getColumnSpan());
Column selectable = (Column) descriptionValue.getColumnIterator().next();
assertEquals((Long) 500L, selectable.getLength());
Component amountMetadata = (Component) investmentMetadata.getProperty("amount").getValue();
SimpleValue currencyMetadata = (SimpleValue) amountMetadata.getProperty("currency").getValue();
CustomType<Object> currencyType = (CustomType<Object>) currencyMetadata.getType();
int[] currencySqlTypes = currencyType.getSqlTypeCodes(metadata);
assertEquals(1, currencySqlTypes.length);
assertJdbcTypeCode(Types.VARCHAR, currencySqlTypes[0]);
} finally {
StandardServiceRegistryBuilder.destroy(ssr);
}
}
use of org.hibernate.testing.orm.junit.FailureExpected in project hibernate-orm by hibernate.
the class EmbeddableWithOne2ManyTest method testBasicOps.
@Test
@FailureExpected(jiraKey = "HHH-4599")
public void testBasicOps(SessionFactoryScope scope) {
Person person = new Person("John", "Dillinger");
scope.inTransaction(session -> {
Alias alias = new Alias("Public Enemy", "Number 1", "FBI");
session.persist(alias);
person.getName().getAliases().add(alias);
session.persist(person);
});
scope.inTransaction(session -> {
Person p = (Person) session.load(Person.class, person.getId());
session.delete(p);
List aliases = session.createQuery("from Alias").list();
assertEquals(0, aliases.size());
});
}
use of org.hibernate.testing.orm.junit.FailureExpected in project hibernate-orm by hibernate.
the class UnidirectionalOneToManyUniqueConstraintOrderColumnTest method testRemovingOneAndAddingTwoElements.
@Test
@FailureExpected(jiraKey = "HHH-1268")
public void testRemovingOneAndAddingTwoElements(EntityManagerFactoryScope scope) {
scope.inTransaction(entityManager -> {
ParentData parent = entityManager.find(ParentData.class, 1L);
List<ChildData> children = parent.getChildren();
children.remove(0);
children.add(1, new ChildData("Another"));
children.add(new ChildData("Another Another"));
});
scope.inEntityManager(entityManager -> {
ParentData parent = entityManager.find(ParentData.class, 1L);
List<String> childIds = parent.getChildren().stream().map(ChildData::toString).collect(Collectors.toList());
int i = 0;
assertEquals("Two", childIds.get(i++));
assertEquals("Another", childIds.get(i++));
assertEquals("Three", childIds.get(i++));
assertEquals("Another Another", childIds.get(i));
});
}
use of org.hibernate.testing.orm.junit.FailureExpected in project hibernate-orm by hibernate.
the class UnidirectionalOneToManyUniqueConstraintOrderColumnTest method testRemovingAndAddingAnElement.
@Test
@FailureExpected(jiraKey = "HHH-1268")
public void testRemovingAndAddingAnElement(EntityManagerFactoryScope scope) {
scope.inTransaction(entityManager -> {
ParentData parent = entityManager.find(ParentData.class, 1L);
List<ChildData> children = parent.getChildren();
children.remove(0);
children.add(1, new ChildData("Another"));
});
scope.inEntityManager(entityManager -> {
ParentData parent = entityManager.find(ParentData.class, 1L);
List<String> childIds = parent.getChildren().stream().map(ChildData::toString).collect(Collectors.toList());
int i = 0;
assertEquals("Two", childIds.get(i++));
assertEquals("Another", childIds.get(i++));
assertEquals("Three", childIds.get(i));
});
}
Aggregations