@Test public void testUniqueResourceId() throws Exception { Resource resource = rootResource(resourceName(),PersonHandler.ID); final Endpoint ep1 = super.endpoint("path1",resource); final Endpoint ep2 = super.endpoint("path2",resource); withinTransaction( new Task<EndpointRepository>("Creating first endpoint") { @Override public void execute(EndpointRepository sut) { sut.add(ep1); } } ); clear(); try { withinTransaction( new Task<EndpointRepository>("Creating endpoint with for the same resource") { @Override public void execute(EndpointRepository sut) { sut.add(ep2); } } ); fail("Should not allowing storing multiple endpoints for the same resource"); } catch (Exception e) { e.printStackTrace(); } }
@Override public void add(Endpoint endpoint) { entityManager().persist(endpoint); }
JPAEndpointRepository implements EndpointRepository { @Override public void add(Endpoint endpoint) { entityManager().persist(endpoint); } }
JPAEndpointRepository implements EndpointRepository { @Override public void add(Endpoint endpoint) { entityManager().persist(endpoint); } JPAEndpointRepository(EntityManagerProvider provider); }
JPAEndpointRepository implements EndpointRepository { @Override public void add(Endpoint endpoint) { entityManager().persist(endpoint); } JPAEndpointRepository(EntityManagerProvider provider); @Override Endpoint endpointOfPath(String path); @Override Endpoint endpointOfResource(ResourceId id); @Override void add(Endpoint endpoint); }
JPAEndpointRepository implements EndpointRepository { @Override public void add(Endpoint endpoint) { entityManager().persist(endpoint); } JPAEndpointRepository(EntityManagerProvider provider); @Override Endpoint endpointOfPath(String path); @Override Endpoint endpointOfResource(ResourceId id); @Override void add(Endpoint endpoint);  }