@Test(expected = ObjectToIdMappingException.class) public void shouldFailWhenIdForAnUnregisteredObjectIsRequested() { Object unknownObject = "example unknown object"; cut.getIdOrFail(unknownObject); }
public UUID getIdOrFail(final Object object) throws ObjectToIdMappingException { Optional<UUID> id = getId(object); if (!id.isPresent()) { throw new ObjectToIdMappingException(format( "An id for the object [%s] was expected to be known but it was not. %s", object.toString(), SYNCRONISM_LOST)); } return id.get(); }
WeakObjectRegistry { public UUID getIdOrFail(final Object object) throws ObjectToIdMappingException { Optional<UUID> id = getId(object); if (!id.isPresent()) { throw new ObjectToIdMappingException(format( "An id for the object [%s] was expected to be known but it was not. %s", object.toString(), SYNCRONISM_LOST)); } return id.get(); } }
WeakObjectRegistry { public UUID getIdOrFail(final Object object) throws ObjectToIdMappingException { Optional<UUID> id = getId(object); if (!id.isPresent()) { throw new ObjectToIdMappingException(format( "An id for the object [%s] was expected to be known but it was not. %s", object.toString(), SYNCRONISM_LOST)); } return id.get(); }  }
WeakObjectRegistry { public UUID getIdOrFail(final Object object) throws ObjectToIdMappingException { Optional<UUID> id = getId(object); if (!id.isPresent()) { throw new ObjectToIdMappingException(format( "An id for the object [%s] was expected to be known but it was not. %s", object.toString(), SYNCRONISM_LOST)); } return id.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 UUID getIdOrFail(final Object object) throws ObjectToIdMappingException { Optional<UUID> id = getId(object); if (!id.isPresent()) { throw new ObjectToIdMappingException(format( "An id for the object [%s] was expected to be known but it was not. %s", object.toString(), SYNCRONISM_LOST)); } return id.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);  }