@Test(expected = ObjectToIdMappingException.class) public void shouldFailWhenObjectForAnUnknownIdIsRequested() { UUID unknownId = UUID.randomUUID(); cut.getByIdOrFail(unknownId); }
public Object getByIdOrFail(final UUID id) throws ObjectToIdMappingException { Optional<Object> object = getById(id); if (!object.isPresent()) { throw new ObjectToIdMappingException(format( "An object with the id [%s] was expected to be known but it was not. %s", id.toString(), SYNCRONISM_LOST)); } return object.get(); }
WeakObjectRegistry { public Object getByIdOrFail(final UUID id) throws ObjectToIdMappingException { Optional<Object> object = getById(id); if (!object.isPresent()) { throw new ObjectToIdMappingException(format( "An object with the id [%s] was expected to be known but it was not. %s", id.toString(), SYNCRONISM_LOST)); } return object.get(); } }
WeakObjectRegistry { public Object getByIdOrFail(final UUID id) throws ObjectToIdMappingException { Optional<Object> object = getById(id); if (!object.isPresent()) { throw new ObjectToIdMappingException(format( "An object with the id [%s] was expected to be known but it was not. %s", id.toString(), SYNCRONISM_LOST)); } return object.get(); }  }
WeakObjectRegistry { public Object getByIdOrFail(final UUID id) throws ObjectToIdMappingException { Optional<Object> object = getById(id); if (!object.isPresent()) { throw new ObjectToIdMappingException(format( "An object with the id [%s] was expected to be known but it was not. %s", id.toString(), SYNCRONISM_LOST)); } return object.get(); }  Optional<Object> getById(final UUID id); Object getByIdOrFail(final UUID id); Optional<UUID> getId(final Object object); UUID getIdOrFail(final Object object); UUID registerIfUnknown(final Object object); void registerObject(final Object object, final UUID id); }
WeakObjectRegistry { public Object getByIdOrFail(final UUID id) throws ObjectToIdMappingException { Optional<Object> object = getById(id); if (!object.isPresent()) { throw new ObjectToIdMappingException(format( "An object with the id [%s] was expected to be known but it was not. %s", id.toString(), SYNCRONISM_LOST)); } return object.get(); }  Optional<Object> getById(final UUID id); Object getByIdOrFail(final UUID id); Optional<UUID> getId(final Object object); UUID getIdOrFail(final Object object); UUID registerIfUnknown(final Object object); void registerObject(final Object object, final UUID id);  }