@Test public void verifyJPQLGeneratorRegistration() { @Include @Entity class Test { @Id private long id; @JPQLFilterFragment(operator = Operator.IN, generator = TestGenerator.class) private String name; } EntityType mockType = mock(EntityType.class); when(mockType.getJavaType()).thenReturn(Test.class); Metamodel mockModel = mock(Metamodel.class); when(mockModel.getEntities()).thenReturn(Sets.newHashSet(mockType)); EntityManager managerMock = mock(EntityManager.class); when(managerMock.getMetamodel()).thenReturn(mockModel); JpaDataStore store = new JpaDataStore(() -> { return managerMock; }, (unused) -> { return null; }); EntityDictionary dictionary = new EntityDictionary(new HashMap<>()); try { store.populateEntityDictionary(dictionary); assertNotNull(FilterTranslator.lookupJPQLGenerator(Operator.IN, Test.class, "name")); } finally { FilterTranslator.registerJPQLGenerator(Operator.IN, Test.class, "name", null); } }
@Override public void populateEntityDictionary(EntityDictionary dictionary) { if (! modelsToBind.isEmpty()) { modelsToBind.stream().forEach((model) -> bindEntityClass(model, dictionary)); return; } for (EntityType type : entityManagerSupplier.get().getMetamodel().getEntities()) { try { Class<?> mappedClass = type.getJavaType(); dictionary.lookupEntityClass(mappedClass); bindEntityClass(mappedClass, dictionary); } catch (IllegalArgumentException e) { } } }
JpaDataStore implements JPQLDataStore { @Override public void populateEntityDictionary(EntityDictionary dictionary) { if (! modelsToBind.isEmpty()) { modelsToBind.stream().forEach((model) -> bindEntityClass(model, dictionary)); return; } for (EntityType type : entityManagerSupplier.get().getMetamodel().getEntities()) { try { Class<?> mappedClass = type.getJavaType(); dictionary.lookupEntityClass(mappedClass); bindEntityClass(mappedClass, dictionary); } catch (IllegalArgumentException e) { } } } }
JpaDataStore implements JPQLDataStore { @Override public void populateEntityDictionary(EntityDictionary dictionary) { if (! modelsToBind.isEmpty()) { modelsToBind.stream().forEach((model) -> bindEntityClass(model, dictionary)); return; } for (EntityType type : entityManagerSupplier.get().getMetamodel().getEntities()) { try { Class<?> mappedClass = type.getJavaType(); dictionary.lookupEntityClass(mappedClass); bindEntityClass(mappedClass, dictionary); } catch (IllegalArgumentException e) { } } } JpaDataStore(EntityManagerSupplier entityManagerSupplier,
                        JpaTransactionSupplier readTransactionSupplier,
                        JpaTransactionSupplier writeTransactionSupplier,
                        Class<?> ... models);  JpaDataStore(EntityManagerSupplier entityManagerSupplier,
                        JpaTransactionSupplier transactionSupplier,
                        Class<?> ... models); }
JpaDataStore implements JPQLDataStore { @Override public void populateEntityDictionary(EntityDictionary dictionary) { if (! modelsToBind.isEmpty()) { modelsToBind.stream().forEach((model) -> bindEntityClass(model, dictionary)); return; } for (EntityType type : entityManagerSupplier.get().getMetamodel().getEntities()) { try { Class<?> mappedClass = type.getJavaType(); dictionary.lookupEntityClass(mappedClass); bindEntityClass(mappedClass, dictionary); } catch (IllegalArgumentException e) { } } } JpaDataStore(EntityManagerSupplier entityManagerSupplier,
                        JpaTransactionSupplier readTransactionSupplier,
                        JpaTransactionSupplier writeTransactionSupplier,
                        Class<?> ... models);  JpaDataStore(EntityManagerSupplier entityManagerSupplier,
                        JpaTransactionSupplier transactionSupplier,
                        Class<?> ... models); @Override void populateEntityDictionary(EntityDictionary dictionary); @Override DataStoreTransaction beginReadTransaction(); @Override DataStoreTransaction beginTransaction(); }
JpaDataStore implements JPQLDataStore { @Override public void populateEntityDictionary(EntityDictionary dictionary) { if (! modelsToBind.isEmpty()) { modelsToBind.stream().forEach((model) -> bindEntityClass(model, dictionary)); return; } for (EntityType type : entityManagerSupplier.get().getMetamodel().getEntities()) { try { Class<?> mappedClass = type.getJavaType(); dictionary.lookupEntityClass(mappedClass); bindEntityClass(mappedClass, dictionary); } catch (IllegalArgumentException e) { } } } JpaDataStore(EntityManagerSupplier entityManagerSupplier,
                        JpaTransactionSupplier readTransactionSupplier,
                        JpaTransactionSupplier writeTransactionSupplier,
                        Class<?> ... models);  JpaDataStore(EntityManagerSupplier entityManagerSupplier,
                        JpaTransactionSupplier transactionSupplier,
                        Class<?> ... models); @Override void populateEntityDictionary(EntityDictionary dictionary); @Override DataStoreTransaction beginReadTransaction(); @Override DataStoreTransaction beginTransaction();  }