BindingDOMEntityOwnershipServiceAdapter implements EntityOwnershipService, AutoCloseable { @Override public EntityOwnershipCandidateRegistration registerCandidate(final Entity entity) throws CandidateAlreadyRegisteredException { return new BindingEntityOwnershipCandidateRegistration( domService.registerCandidate(toDOMEntity(entity)), entity); } @Inject  BindingDOMEntityOwnershipServiceAdapter(final @NonNull DOMEntityOwnershipService domService,
            final @NonNull AdapterContext adapterContext); @Override EntityOwnershipCandidateRegistration registerCandidate(final Entity entity); @Override EntityOwnershipListenerRegistration registerListener(final String entityType,
            final EntityOwnershipListener listener); @Override Optional<EntityOwnershipState> getOwnershipState(final Entity forEntity); @Override boolean isCandidateRegistered(final Entity forEntity); @Override void close();  }
@Test public void testRegisterCandidate() throws CandidateAlreadyRegisteredException { final DOMEntityOwnershipCandidateRegistration mockDOMReg = mock(DOMEntityOwnershipCandidateRegistration.class); doReturn(mockDOMReg).when(this.mockDOMService).registerCandidate(DOM_ENTITY); final EntityOwnershipCandidateRegistration reg = this.adapter.registerCandidate(BINDING_ENTITY); assertNotNull("registerCandidate returned null", reg); assertEquals("getInstance", BINDING_ENTITY, reg.getInstance()); reg.close(); verify(mockDOMReg).close(); }