-
Notifications
You must be signed in to change notification settings - Fork 83
Description
Hello,
i'm trying to implement a mock OData server using the jpa-processor, in order to be able to write E2E tests for a flow involving an OData service. The real OData server is not under my control and defines some entities, properties etc. with names in kebab case, like the following:
<EntityType Name="elm_role" BaseType="mscrm.crmbaseentity">
<Key>
<PropertyRef Name="elm_role_id" />
</Key>
<Property Name="elm_role_name" Type="Edm.String">
...
</EntityType>
I do not want to define the JPA entity attributes in kebab case, and even if i do, i cannot (for example) do the same thing for the entity itself (it's a class).
Is there a way to define the desired name(s) for these entities, properties, and leave everything else to the processor? I tried to register a custom JPAEdmNameBuilder in the servlet the way shown in the following code snippet but with no luck.
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException {
try {
EntityManagerFactory emf = JPAEntityManagerFactory.getEntityManagerFactory(PUNIT_NAME, new HashMap<>());
JPAEdmProvider provider = new JPAEdmProvider(emf, null, new String[] { PACKAGE_NAME }, new ElmNameBuilder(NAMESPACE));
OData odata = OData.newInstance();
ServiceMetadata edm = odata.createServiceMetadata(provider, new ArrayList<>());
odata.createHandler(edm).process(request, response);
} catch (Exception e) {
throw new ServletException(e);
}
}
Is the JPAEdmNameBuilder the way to go? If not, is there some other option?
I understand that for a server under my control the whole thing would not be an issue, but still it would be nice to have a way to handle it.
Thank you.