@Test(expected = BeanValidationException.class) public void testStore_Validation() { storage.store(new UserIdentifier(), null); }
public void store(@NotNull UserIdentifier userId, @NotNull Object entity) throws ServiceException { LOG.debug("Storing file for {}", userId); Path histPath = getPath(userId, entity.getClass()); try (FileChannel channel = openForWrite(histPath)) { String jsonText = jsonMarshaller.marshal(entity); ByteBuffer buf = encoder.get().encode(CharBuffer.wrap(jsonText)); int written = channel.write(buf); channel.truncate(written); } catch (IOException | SecurityException | IllegalStateException e) { throw new ServiceException("Error storing query history in:" + histPath + " - " + e.getClass() + " - " + e.getMessage(), e); } LOG.trace("File has been sotred {}", entity); }
FileStorage { public void store(@NotNull UserIdentifier userId, @NotNull Object entity) throws ServiceException { LOG.debug("Storing file for {}", userId); Path histPath = getPath(userId, entity.getClass()); try (FileChannel channel = openForWrite(histPath)) { String jsonText = jsonMarshaller.marshal(entity); ByteBuffer buf = encoder.get().encode(CharBuffer.wrap(jsonText)); int written = channel.write(buf); channel.truncate(written); } catch (IOException | SecurityException | IllegalStateException e) { throw new ServiceException("Error storing query history in:" + histPath + " - " + e.getClass() + " - " + e.getMessage(), e); } LOG.trace("File has been sotred {}", entity); } }
FileStorage { public void store(@NotNull UserIdentifier userId, @NotNull Object entity) throws ServiceException { LOG.debug("Storing file for {}", userId); Path histPath = getPath(userId, entity.getClass()); try (FileChannel channel = openForWrite(histPath)) { String jsonText = jsonMarshaller.marshal(entity); ByteBuffer buf = encoder.get().encode(CharBuffer.wrap(jsonText)); int written = channel.write(buf); channel.truncate(written); } catch (IOException | SecurityException | IllegalStateException e) { throw new ServiceException("Error storing query history in:" + histPath + " - " + e.getClass() + " - " + e.getMessage(), e); } LOG.trace("File has been sotred {}", entity); }  }
FileStorage { public void store(@NotNull UserIdentifier userId, @NotNull Object entity) throws ServiceException { LOG.debug("Storing file for {}", userId); Path histPath = getPath(userId, entity.getClass()); try (FileChannel channel = openForWrite(histPath)) { String jsonText = jsonMarshaller.marshal(entity); ByteBuffer buf = encoder.get().encode(CharBuffer.wrap(jsonText)); int written = channel.write(buf); channel.truncate(written); } catch (IOException | SecurityException | IllegalStateException e) { throw new ServiceException("Error storing query history in:" + histPath + " - " + e.getClass() + " - " + e.getMessage(), e); } LOG.trace("File has been sotred {}", entity); }  boolean supported(); void store(@NotNull UserIdentifier userId, @NotNull Object entity); @Valid Optional<T> read(@NotNull UserIdentifier userId, @NotNull Class<T> clazz); int getLockRetryCount(); }
FileStorage { public void store(@NotNull UserIdentifier userId, @NotNull Object entity) throws ServiceException { LOG.debug("Storing file for {}", userId); Path histPath = getPath(userId, entity.getClass()); try (FileChannel channel = openForWrite(histPath)) { String jsonText = jsonMarshaller.marshal(entity); ByteBuffer buf = encoder.get().encode(CharBuffer.wrap(jsonText)); int written = channel.write(buf); channel.truncate(written); } catch (IOException | SecurityException | IllegalStateException e) { throw new ServiceException("Error storing query history in:" + histPath + " - " + e.getClass() + " - " + e.getMessage(), e); } LOG.trace("File has been sotred {}", entity); }  boolean supported(); void store(@NotNull UserIdentifier userId, @NotNull Object entity); @Valid Optional<T> read(@NotNull UserIdentifier userId, @NotNull Class<T> clazz); int getLockRetryCount();  }