target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void testAddMessageReTrigger() throws Exception { addNumberOfMessages(2 * MESSAGE_THRESHOLD); verify(collector, times(2)).onDrain(anyListOf(ClientMessage.class)); } | private void onDrain() { ImmutableList<ClientMessage> immutable; LOGGER.trace("Draining {} collected messsages...", collectedMessages.size()); synchronized (collectedMessages) { immutable = ImmutableList.copyOf(collectedMessages); collectedMessages.clear(); } for (CollectedMessageConsumer drain : consumers) { drain.onDrain(immutable); } } | MessageCollector { private void onDrain() { ImmutableList<ClientMessage> immutable; LOGGER.trace("Draining {} collected messsages...", collectedMessages.size()); synchronized (collectedMessages) { immutable = ImmutableList.copyOf(collectedMessages); collectedMessages.clear(); } for (CollectedMessageConsumer drain : consumers) { drain.onDrain(immutable); } } } | MessageCollector { private void onDrain() { ImmutableList<ClientMessage> immutable; LOGGER.trace("Draining {} collected messsages...", collectedMessages.size()); synchronized (collectedMessages) { immutable = ImmutableList.copyOf(collectedMessages); collectedMessages.clear(); } for (CollectedMessageConsumer drain : consumers) { drain.onDrain(immutable); } } MessageCollector(int collectedMessageThreshold, CollectedMessageConsumer... consumers); } | MessageCollector { private void onDrain() { ImmutableList<ClientMessage> immutable; LOGGER.trace("Draining {} collected messsages...", collectedMessages.size()); synchronized (collectedMessages) { immutable = ImmutableList.copyOf(collectedMessages); collectedMessages.clear(); } for (CollectedMessageConsumer drain : consumers) { drain.onDrain(immutable); } } MessageCollector(int collectedMessageThreshold, CollectedMessageConsumer... consumers); void addMessage(ClientMessage message); void drain(); } | MessageCollector { private void onDrain() { ImmutableList<ClientMessage> immutable; LOGGER.trace("Draining {} collected messsages...", collectedMessages.size()); synchronized (collectedMessages) { immutable = ImmutableList.copyOf(collectedMessages); collectedMessages.clear(); } for (CollectedMessageConsumer drain : consumers) { drain.onDrain(immutable); } } MessageCollector(int collectedMessageThreshold, CollectedMessageConsumer... consumers); void addMessage(ClientMessage message); void drain(); } |
@Test public void testMetricPendingMessagesTrack() throws Exception { ClientMessage message = messageFactory.trackPath(Paths.get(TEST_PATH), UUID); cut.onMessage(message); assertThat(metrics.getCounters().get(TaskMessageHandler.METRIC_NAME_PENDING_MESSAGES).getCount(), is(1L)); } | @Override public void onMessage(ClientMessage msg) { try { if (isTaskType(msg, TaskType.track)) { String path = msg.getStringProperty(MessageProperty.path.toString()); long most = msg.getBodyBuffer().readLong(); long least = msg.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Tracking new path {} with UUID {}", path, new UUID(most, least)); } pendingMessages.inc(); pendingRepository.store(new PendingHashImage(path, most, least)); } else { LOGGER.error("Unhandled message: {}", msg); } } catch (RepositoryException e) { String cause = "unknown"; if(e.getCause() != null) { cause = e.getCause().toString(); } LOGGER.warn("Failed to store result message: {}, cause:{}", e.toString(), cause); } } | TaskMessageHandler implements MessageHandler { @Override public void onMessage(ClientMessage msg) { try { if (isTaskType(msg, TaskType.track)) { String path = msg.getStringProperty(MessageProperty.path.toString()); long most = msg.getBodyBuffer().readLong(); long least = msg.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Tracking new path {} with UUID {}", path, new UUID(most, least)); } pendingMessages.inc(); pendingRepository.store(new PendingHashImage(path, most, least)); } else { LOGGER.error("Unhandled message: {}", msg); } } catch (RepositoryException e) { String cause = "unknown"; if(e.getCause() != null) { cause = e.getCause().toString(); } LOGGER.warn("Failed to store result message: {}, cause:{}", e.toString(), cause); } } } | TaskMessageHandler implements MessageHandler { @Override public void onMessage(ClientMessage msg) { try { if (isTaskType(msg, TaskType.track)) { String path = msg.getStringProperty(MessageProperty.path.toString()); long most = msg.getBodyBuffer().readLong(); long least = msg.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Tracking new path {} with UUID {}", path, new UUID(most, least)); } pendingMessages.inc(); pendingRepository.store(new PendingHashImage(path, most, least)); } else { LOGGER.error("Unhandled message: {}", msg); } } catch (RepositoryException e) { String cause = "unknown"; if(e.getCause() != null) { cause = e.getCause().toString(); } LOGGER.warn("Failed to store result message: {}, cause:{}", e.toString(), cause); } } @Inject TaskMessageHandler(PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
MetricRegistry metrics); @Deprecated TaskMessageHandler(PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
ClientSession session, MetricRegistry metrics); @Deprecated TaskMessageHandler(PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
ClientSession session, String eaUpdateAddress, MetricRegistry metrics); TaskMessageHandler(PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
String eaUpdateAddress, MetricRegistry metrics); } | TaskMessageHandler implements MessageHandler { @Override public void onMessage(ClientMessage msg) { try { if (isTaskType(msg, TaskType.track)) { String path = msg.getStringProperty(MessageProperty.path.toString()); long most = msg.getBodyBuffer().readLong(); long least = msg.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Tracking new path {} with UUID {}", path, new UUID(most, least)); } pendingMessages.inc(); pendingRepository.store(new PendingHashImage(path, most, least)); } else { LOGGER.error("Unhandled message: {}", msg); } } catch (RepositoryException e) { String cause = "unknown"; if(e.getCause() != null) { cause = e.getCause().toString(); } LOGGER.warn("Failed to store result message: {}, cause:{}", e.toString(), cause); } } @Inject TaskMessageHandler(PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
MetricRegistry metrics); @Deprecated TaskMessageHandler(PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
ClientSession session, MetricRegistry metrics); @Deprecated TaskMessageHandler(PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
ClientSession session, String eaUpdateAddress, MetricRegistry metrics); TaskMessageHandler(PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
String eaUpdateAddress, MetricRegistry metrics); @Override void onMessage(ClientMessage msg); } | TaskMessageHandler implements MessageHandler { @Override public void onMessage(ClientMessage msg) { try { if (isTaskType(msg, TaskType.track)) { String path = msg.getStringProperty(MessageProperty.path.toString()); long most = msg.getBodyBuffer().readLong(); long least = msg.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Tracking new path {} with UUID {}", path, new UUID(most, least)); } pendingMessages.inc(); pendingRepository.store(new PendingHashImage(path, most, least)); } else { LOGGER.error("Unhandled message: {}", msg); } } catch (RepositoryException e) { String cause = "unknown"; if(e.getCause() != null) { cause = e.getCause().toString(); } LOGGER.warn("Failed to store result message: {}, cause:{}", e.toString(), cause); } } @Inject TaskMessageHandler(PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
MetricRegistry metrics); @Deprecated TaskMessageHandler(PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
ClientSession session, MetricRegistry metrics); @Deprecated TaskMessageHandler(PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
ClientSession session, String eaUpdateAddress, MetricRegistry metrics); TaskMessageHandler(PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
String eaUpdateAddress, MetricRegistry metrics); @Override void onMessage(ClientMessage msg); static final String METRIC_NAME_PENDING_MESSAGES; } |
@Test public void testStop() throws Exception { cut.stop(); verify(collector, timeout(VERIFY_TIMEOUT)).drain(); verify(consumer).close(); } | @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } | ResultMessageSink implements Node { @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } } | ResultMessageSink implements Node { @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } ResultMessageSink(ClientSession transactedSession, MessageCollector collector, String resultQueueName,
long messageIdleTimeout); ResultMessageSink(ClientSession transactedSession, MessageCollector collector); } | ResultMessageSink implements Node { @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } ResultMessageSink(ClientSession transactedSession, MessageCollector collector, String resultQueueName,
long messageIdleTimeout); ResultMessageSink(ClientSession transactedSession, MessageCollector collector); @Override void stop(); } | ResultMessageSink implements Node { @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } ResultMessageSink(ClientSession transactedSession, MessageCollector collector, String resultQueueName,
long messageIdleTimeout); ResultMessageSink(ClientSession transactedSession, MessageCollector collector); @Override void stop(); } |
@Test(timeout = TEST_TIMEOUT) public void testDrainOnNoMessage() throws Exception { cut.stop(); Mockito.reset(collector); when(consumer.receive(anyLong())).thenReturn(null); cut = new ResultMessageSink(session, collector); verify(collector, timeout(VERIFY_TIMEOUT).atLeastOnce()).drain(); verify(collector, never()).addMessage(message); } | @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } | ResultMessageSink implements Node { @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } } | ResultMessageSink implements Node { @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } ResultMessageSink(ClientSession transactedSession, MessageCollector collector, String resultQueueName,
long messageIdleTimeout); ResultMessageSink(ClientSession transactedSession, MessageCollector collector); } | ResultMessageSink implements Node { @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } ResultMessageSink(ClientSession transactedSession, MessageCollector collector, String resultQueueName,
long messageIdleTimeout); ResultMessageSink(ClientSession transactedSession, MessageCollector collector); @Override void stop(); } | ResultMessageSink implements Node { @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } ResultMessageSink(ClientSession transactedSession, MessageCollector collector, String resultQueueName,
long messageIdleTimeout); ResultMessageSink(ClientSession transactedSession, MessageCollector collector); @Override void stop(); } |
@Test public void testMessageReadFailure() throws Exception { cut.stop(); Mockito.reset(collector); when(consumer.receive(anyLong())).thenThrow(new ActiveMQException("test")); cut = new ResultMessageSink(session, collector); verify(collector, atMost(1)).drain(); verify(collector, never()).addMessage(any(ClientMessage.class)); } | @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } | ResultMessageSink implements Node { @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } } | ResultMessageSink implements Node { @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } ResultMessageSink(ClientSession transactedSession, MessageCollector collector, String resultQueueName,
long messageIdleTimeout); ResultMessageSink(ClientSession transactedSession, MessageCollector collector); } | ResultMessageSink implements Node { @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } ResultMessageSink(ClientSession transactedSession, MessageCollector collector, String resultQueueName,
long messageIdleTimeout); ResultMessageSink(ClientSession transactedSession, MessageCollector collector); @Override void stop(); } | ResultMessageSink implements Node { @Override public void stop() { LOGGER.info("Stopping {}", WORKER_THREAD_NAME); sink.interrupt(); try { sink.join(); } catch (InterruptedException ie) { LOGGER.warn("Interrupted while wating for sink to terminate: {}", ie.toString()); } try { consumer.close(); } catch (ActiveMQException e) { LOGGER.warn("Failed to close consumer: {}", e.toString()); } } ResultMessageSink(ClientSession transactedSession, MessageCollector collector, String resultQueueName,
long messageIdleTimeout); ResultMessageSink(ClientSession transactedSession, MessageCollector collector); @Override void stop(); } |
@Test public void testBufferResize() throws Exception { hashRequestMessage = messageFactory.hashRequestMessage(new byte[LARGE_DATA_SIZE], TEST_UUID); cut.onMessage(hashRequestMessage); assertThat(metrics.getMeters().get(HasherNode.METRIC_NAME_BUFFER_RESIZE).getCount(), is(1L)); } | @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } | HasherNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } } | HasherNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); } | HasherNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); @Override void stop(); @Override String toString(); @Override void onMessage(ClientMessage message); } | HasherNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); @Override void stop(); @Override String toString(); @Override void onMessage(ClientMessage message); static final String METRIC_NAME_HASH_MESSAGES; static final String METRIC_NAME_HASH_DURATION; static final String METRIC_NAME_BUFFER_RESIZE; } |
@Test public void testReadAllData() throws Exception { byte[] read = new byte[TEST_DATA.length]; input.read(read); assertThat(read, is(TEST_DATA)); } | @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } | ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } } | ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } ByteBufferInputstream(ByteBuffer buffer); } | ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } ByteBufferInputstream(ByteBuffer buffer); @Override int read(); @Override int available(); } | ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } ByteBufferInputstream(ByteBuffer buffer); @Override int read(); @Override int available(); } |
@Test public void testHashDuration() throws Exception { cut.onMessage(hashRequestMessage); assertThat(metrics.getTimers().get(HasherNode.METRIC_NAME_HASH_DURATION).getSnapshot().getMean(), is(not(0.0))); } | @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } | HasherNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } } | HasherNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); } | HasherNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); @Override void stop(); @Override String toString(); @Override void onMessage(ClientMessage message); } | HasherNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); @Override void stop(); @Override String toString(); @Override void onMessage(ClientMessage message); static final String METRIC_NAME_HASH_MESSAGES; static final String METRIC_NAME_HASH_DURATION; static final String METRIC_NAME_BUFFER_RESIZE; } |
@Test public void testHashDurationOnFailure() throws Exception { Mockito.reset(hasher); when(hasher.getLongHash(nullable(BufferedImage.class))).thenThrow(new IOException("Testing")); cut.onMessage(hashRequestMessage); assertThat(metrics.getTimers().get(HasherNode.METRIC_NAME_HASH_DURATION).getSnapshot().getMean(), is(0.0)); } | @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } | HasherNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } } | HasherNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); } | HasherNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); @Override void stop(); @Override String toString(); @Override void onMessage(ClientMessage message); } | HasherNode implements MessageHandler, Node { @Override public void onMessage(ClientMessage message) { hashRequests.mark(); Context hashTimeContext = hashDuration.time(); try { long most = message.getBodyBuffer().readLong(); long least = message.getBodyBuffer().readLong(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Got hash request with UUID {}, size {}", new UUID(most, least), message.getBodySize()); } checkBufferCapacity(message.getBodySize()); buffer.limit(message.getBodySize()); LOGGER.trace("Reading resized image with size {}", message.getBodySize()); buffer.rewind(); message.getBodyBuffer().readBytes(buffer); buffer.rewind(); long hash = doHash(ImageIO.read(new ByteBufferInputstream(buffer))); ClientMessage response = messageFactory.resultMessage(hash, most, least); producer.send(response); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sent result for request with UUID {} to {}", new UUID(most, least), producer.getAddress()); } hashTimeContext.stop(); } catch (ActiveMQException e) { LOGGER.error("Failed to process message: {}", e.toString()); } catch (Exception e) { LOGGER.error("Failed to process image: {}", e.toString()); } } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); @Override void stop(); @Override String toString(); @Override void onMessage(ClientMessage message); static final String METRIC_NAME_HASH_MESSAGES; static final String METRIC_NAME_HASH_DURATION; static final String METRIC_NAME_BUFFER_RESIZE; } |
@Test public void testToStringStart() throws Exception { assertThat(cut.toString(), startsWith("HasherNode {")); } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(HasherNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } | HasherNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(HasherNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } } | HasherNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(HasherNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); } | HasherNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(HasherNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); @Override void stop(); @Override String toString(); @Override void onMessage(ClientMessage message); } | HasherNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(HasherNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); @Override void stop(); @Override String toString(); @Override void onMessage(ClientMessage message); static final String METRIC_NAME_HASH_MESSAGES; static final String METRIC_NAME_HASH_DURATION; static final String METRIC_NAME_BUFFER_RESIZE; } |
@Test public void testToStringEnd() throws Exception { assertThat(cut.toString(), endsWith("}")); } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(HasherNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } | HasherNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(HasherNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } } | HasherNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(HasherNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); } | HasherNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(HasherNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); @Override void stop(); @Override String toString(); @Override void onMessage(ClientMessage message); } | HasherNode implements MessageHandler, Node { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(HasherNode.class.getSimpleName()).append(" {").append(identity.toString()).append("}"); return sb.toString(); } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); @Override void stop(); @Override String toString(); @Override void onMessage(ClientMessage message); static final String METRIC_NAME_HASH_MESSAGES; static final String METRIC_NAME_HASH_DURATION; static final String METRIC_NAME_BUFFER_RESIZE; } |
@Test public void testStop() throws Exception { cut.stop(); assertThat(session.isClosed(), is(true)); } | @Override public void stop() { LOGGER.info("Stopping {}...", this.toString()); MessagingUtil.silentClose(consumer); MessagingUtil.silentClose(producer); MessagingUtil.silentClose(session); } | HasherNode implements MessageHandler, Node { @Override public void stop() { LOGGER.info("Stopping {}...", this.toString()); MessagingUtil.silentClose(consumer); MessagingUtil.silentClose(producer); MessagingUtil.silentClose(session); } } | HasherNode implements MessageHandler, Node { @Override public void stop() { LOGGER.info("Stopping {}...", this.toString()); MessagingUtil.silentClose(consumer); MessagingUtil.silentClose(producer); MessagingUtil.silentClose(session); } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); } | HasherNode implements MessageHandler, Node { @Override public void stop() { LOGGER.info("Stopping {}...", this.toString()); MessagingUtil.silentClose(consumer); MessagingUtil.silentClose(producer); MessagingUtil.silentClose(session); } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); @Override void stop(); @Override String toString(); @Override void onMessage(ClientMessage message); } | HasherNode implements MessageHandler, Node { @Override public void stop() { LOGGER.info("Stopping {}...", this.toString()); MessagingUtil.silentClose(consumer); MessagingUtil.silentClose(producer); MessagingUtil.silentClose(session); } HasherNode(ClientSession session, ImagePHash hasher, String requestAddress, String resultAddress,
MetricRegistry metrics); @Override void stop(); @Override String toString(); @Override void onMessage(ClientMessage message); static final String METRIC_NAME_HASH_MESSAGES; static final String METRIC_NAME_HASH_DURATION; static final String METRIC_NAME_BUFFER_RESIZE; } |
@Test public void testQueryPending() throws Exception { List<String> pending = queryMessage.pendingImagePaths(); assertThat(pending, hasItem(PATH.toString())); } | @Override public String toString() { return RepositoryNode.class.getSimpleName(); } | RepositoryNode implements MessageHandler, Node { @Override public String toString() { return RepositoryNode.class.getSimpleName(); } } | RepositoryNode implements MessageHandler, Node { @Override public String toString() { return RepositoryNode.class.getSimpleName(); } RepositoryNode(ClientSession session, String queryAddress, String taskAddress,
PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
TaskMessageHandler taskMessageHandler, MetricRegistry metrics); @Inject RepositoryNode(@Named("normal") ClientSession session, PendingHashImageRepository pendingRepository,
TaskMessageHandler taskMessageHandler, MetricRegistry metrics); } | RepositoryNode implements MessageHandler, Node { @Override public String toString() { return RepositoryNode.class.getSimpleName(); } RepositoryNode(ClientSession session, String queryAddress, String taskAddress,
PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
TaskMessageHandler taskMessageHandler, MetricRegistry metrics); @Inject RepositoryNode(@Named("normal") ClientSession session, PendingHashImageRepository pendingRepository,
TaskMessageHandler taskMessageHandler, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); } | RepositoryNode implements MessageHandler, Node { @Override public String toString() { return RepositoryNode.class.getSimpleName(); } RepositoryNode(ClientSession session, String queryAddress, String taskAddress,
PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
TaskMessageHandler taskMessageHandler, MetricRegistry metrics); @Inject RepositoryNode(@Named("normal") ClientSession session, PendingHashImageRepository pendingRepository,
TaskMessageHandler taskMessageHandler, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); } |
@Test public void testToString() throws Exception { assertThat(cut.toString(), is("RepositoryNode")); } | @Override public String toString() { return RepositoryNode.class.getSimpleName(); } | RepositoryNode implements MessageHandler, Node { @Override public String toString() { return RepositoryNode.class.getSimpleName(); } } | RepositoryNode implements MessageHandler, Node { @Override public String toString() { return RepositoryNode.class.getSimpleName(); } RepositoryNode(ClientSession session, String queryAddress, String taskAddress,
PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
TaskMessageHandler taskMessageHandler, MetricRegistry metrics); @Inject RepositoryNode(@Named("normal") ClientSession session, PendingHashImageRepository pendingRepository,
TaskMessageHandler taskMessageHandler, MetricRegistry metrics); } | RepositoryNode implements MessageHandler, Node { @Override public String toString() { return RepositoryNode.class.getSimpleName(); } RepositoryNode(ClientSession session, String queryAddress, String taskAddress,
PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
TaskMessageHandler taskMessageHandler, MetricRegistry metrics); @Inject RepositoryNode(@Named("normal") ClientSession session, PendingHashImageRepository pendingRepository,
TaskMessageHandler taskMessageHandler, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); } | RepositoryNode implements MessageHandler, Node { @Override public String toString() { return RepositoryNode.class.getSimpleName(); } RepositoryNode(ClientSession session, String queryAddress, String taskAddress,
PendingHashImageRepository pendingRepository, ImageRepository imageRepository,
TaskMessageHandler taskMessageHandler, MetricRegistry metrics); @Inject RepositoryNode(@Named("normal") ClientSession session, PendingHashImageRepository pendingRepository,
TaskMessageHandler taskMessageHandler, MetricRegistry metrics); @Override void onMessage(ClientMessage message); @Override void stop(); @Override String toString(); } |
@Test public void testProcessFile() throws Exception { cut.processFile(testFile); await().until(messages::size, is(1)); ClientMessage message = messages.get(0); assertThat(message.getStringProperty(MessageProperty.path.toString()), is(testFile.toString())); } | public boolean processFile(Path path) { LOGGER.trace("Processing {}", path); if (isAlreadySent(path)) { LOGGER.trace("File {} has already been sent, ignoring...", path); return true; } try (InputStream bis = new BufferedInputStream(Files.newInputStream(path))) { ClientMessage request = messageFactory.resizeRequest(path, bis); producer.send(request); sentRequests.put(path, 0); LOGGER.trace("Sent resize request for {}", path); return true; } catch (IOException e) { LOGGER.warn("Failed to access file {}: {}", path, e.toString()); } catch (ActiveMQException e) { LOGGER.warn("Failed to send resize request for {}: {}", path, e.toString()); } return false; } | StorageNode implements MessageHandler, Node { public boolean processFile(Path path) { LOGGER.trace("Processing {}", path); if (isAlreadySent(path)) { LOGGER.trace("File {} has already been sent, ignoring...", path); return true; } try (InputStream bis = new BufferedInputStream(Files.newInputStream(path))) { ClientMessage request = messageFactory.resizeRequest(path, bis); producer.send(request); sentRequests.put(path, 0); LOGGER.trace("Sent resize request for {}", path); return true; } catch (IOException e) { LOGGER.warn("Failed to access file {}: {}", path, e.toString()); } catch (ActiveMQException e) { LOGGER.warn("Failed to send resize request for {}: {}", path, e.toString()); } return false; } } | StorageNode implements MessageHandler, Node { public boolean processFile(Path path) { LOGGER.trace("Processing {}", path); if (isAlreadySent(path)) { LOGGER.trace("File {} has already been sent, ignoring...", path); return true; } try (InputStream bis = new BufferedInputStream(Files.newInputStream(path))) { ClientMessage request = messageFactory.resizeRequest(path, bis); producer.send(request); sentRequests.put(path, 0); LOGGER.trace("Sent resize request for {}", path); return true; } catch (IOException e) { LOGGER.warn("Failed to access file {}: {}", path, e.toString()); } catch (ActiveMQException e) { LOGGER.warn("Failed to send resize request for {}: {}", path, e.toString()); } return false; } StorageNode(ClientSession session, ExtendedAttributeQuery eaQuery, HashAttribute hashAttribute, List<Path> pendingPaths,
String resizeAddress, String eaUpdateAddress); @Inject StorageNode(@Named("normal") ClientSession session, ExtendedAttributeQuery eaQuery,
HashAttribute hashAttribute, @Named("pending") List<Path> pendingPaths); } | StorageNode implements MessageHandler, Node { public boolean processFile(Path path) { LOGGER.trace("Processing {}", path); if (isAlreadySent(path)) { LOGGER.trace("File {} has already been sent, ignoring...", path); return true; } try (InputStream bis = new BufferedInputStream(Files.newInputStream(path))) { ClientMessage request = messageFactory.resizeRequest(path, bis); producer.send(request); sentRequests.put(path, 0); LOGGER.trace("Sent resize request for {}", path); return true; } catch (IOException e) { LOGGER.warn("Failed to access file {}: {}", path, e.toString()); } catch (ActiveMQException e) { LOGGER.warn("Failed to send resize request for {}: {}", path, e.toString()); } return false; } StorageNode(ClientSession session, ExtendedAttributeQuery eaQuery, HashAttribute hashAttribute, List<Path> pendingPaths,
String resizeAddress, String eaUpdateAddress); @Inject StorageNode(@Named("normal") ClientSession session, ExtendedAttributeQuery eaQuery,
HashAttribute hashAttribute, @Named("pending") List<Path> pendingPaths); @Override void onMessage(ClientMessage message); boolean processFile(Path path); @Override void stop(); @Override String toString(); } | StorageNode implements MessageHandler, Node { public boolean processFile(Path path) { LOGGER.trace("Processing {}", path); if (isAlreadySent(path)) { LOGGER.trace("File {} has already been sent, ignoring...", path); return true; } try (InputStream bis = new BufferedInputStream(Files.newInputStream(path))) { ClientMessage request = messageFactory.resizeRequest(path, bis); producer.send(request); sentRequests.put(path, 0); LOGGER.trace("Sent resize request for {}", path); return true; } catch (IOException e) { LOGGER.warn("Failed to access file {}: {}", path, e.toString()); } catch (ActiveMQException e) { LOGGER.warn("Failed to send resize request for {}: {}", path, e.toString()); } return false; } StorageNode(ClientSession session, ExtendedAttributeQuery eaQuery, HashAttribute hashAttribute, List<Path> pendingPaths,
String resizeAddress, String eaUpdateAddress); @Inject StorageNode(@Named("normal") ClientSession session, ExtendedAttributeQuery eaQuery,
HashAttribute hashAttribute, @Named("pending") List<Path> pendingPaths); @Override void onMessage(ClientMessage message); boolean processFile(Path path); @Override void stop(); @Override String toString(); } |
@Test public void testProcessFileSkipDuplicateCached() throws Exception { cut.processFile(cachedFile); await().pollDelay(1, TimeUnit.SECONDS).until(messages::size, is(0)); } | public boolean processFile(Path path) { LOGGER.trace("Processing {}", path); if (isAlreadySent(path)) { LOGGER.trace("File {} has already been sent, ignoring...", path); return true; } try (InputStream bis = new BufferedInputStream(Files.newInputStream(path))) { ClientMessage request = messageFactory.resizeRequest(path, bis); producer.send(request); sentRequests.put(path, 0); LOGGER.trace("Sent resize request for {}", path); return true; } catch (IOException e) { LOGGER.warn("Failed to access file {}: {}", path, e.toString()); } catch (ActiveMQException e) { LOGGER.warn("Failed to send resize request for {}: {}", path, e.toString()); } return false; } | StorageNode implements MessageHandler, Node { public boolean processFile(Path path) { LOGGER.trace("Processing {}", path); if (isAlreadySent(path)) { LOGGER.trace("File {} has already been sent, ignoring...", path); return true; } try (InputStream bis = new BufferedInputStream(Files.newInputStream(path))) { ClientMessage request = messageFactory.resizeRequest(path, bis); producer.send(request); sentRequests.put(path, 0); LOGGER.trace("Sent resize request for {}", path); return true; } catch (IOException e) { LOGGER.warn("Failed to access file {}: {}", path, e.toString()); } catch (ActiveMQException e) { LOGGER.warn("Failed to send resize request for {}: {}", path, e.toString()); } return false; } } | StorageNode implements MessageHandler, Node { public boolean processFile(Path path) { LOGGER.trace("Processing {}", path); if (isAlreadySent(path)) { LOGGER.trace("File {} has already been sent, ignoring...", path); return true; } try (InputStream bis = new BufferedInputStream(Files.newInputStream(path))) { ClientMessage request = messageFactory.resizeRequest(path, bis); producer.send(request); sentRequests.put(path, 0); LOGGER.trace("Sent resize request for {}", path); return true; } catch (IOException e) { LOGGER.warn("Failed to access file {}: {}", path, e.toString()); } catch (ActiveMQException e) { LOGGER.warn("Failed to send resize request for {}: {}", path, e.toString()); } return false; } StorageNode(ClientSession session, ExtendedAttributeQuery eaQuery, HashAttribute hashAttribute, List<Path> pendingPaths,
String resizeAddress, String eaUpdateAddress); @Inject StorageNode(@Named("normal") ClientSession session, ExtendedAttributeQuery eaQuery,
HashAttribute hashAttribute, @Named("pending") List<Path> pendingPaths); } | StorageNode implements MessageHandler, Node { public boolean processFile(Path path) { LOGGER.trace("Processing {}", path); if (isAlreadySent(path)) { LOGGER.trace("File {} has already been sent, ignoring...", path); return true; } try (InputStream bis = new BufferedInputStream(Files.newInputStream(path))) { ClientMessage request = messageFactory.resizeRequest(path, bis); producer.send(request); sentRequests.put(path, 0); LOGGER.trace("Sent resize request for {}", path); return true; } catch (IOException e) { LOGGER.warn("Failed to access file {}: {}", path, e.toString()); } catch (ActiveMQException e) { LOGGER.warn("Failed to send resize request for {}: {}", path, e.toString()); } return false; } StorageNode(ClientSession session, ExtendedAttributeQuery eaQuery, HashAttribute hashAttribute, List<Path> pendingPaths,
String resizeAddress, String eaUpdateAddress); @Inject StorageNode(@Named("normal") ClientSession session, ExtendedAttributeQuery eaQuery,
HashAttribute hashAttribute, @Named("pending") List<Path> pendingPaths); @Override void onMessage(ClientMessage message); boolean processFile(Path path); @Override void stop(); @Override String toString(); } | StorageNode implements MessageHandler, Node { public boolean processFile(Path path) { LOGGER.trace("Processing {}", path); if (isAlreadySent(path)) { LOGGER.trace("File {} has already been sent, ignoring...", path); return true; } try (InputStream bis = new BufferedInputStream(Files.newInputStream(path))) { ClientMessage request = messageFactory.resizeRequest(path, bis); producer.send(request); sentRequests.put(path, 0); LOGGER.trace("Sent resize request for {}", path); return true; } catch (IOException e) { LOGGER.warn("Failed to access file {}: {}", path, e.toString()); } catch (ActiveMQException e) { LOGGER.warn("Failed to send resize request for {}: {}", path, e.toString()); } return false; } StorageNode(ClientSession session, ExtendedAttributeQuery eaQuery, HashAttribute hashAttribute, List<Path> pendingPaths,
String resizeAddress, String eaUpdateAddress); @Inject StorageNode(@Named("normal") ClientSession session, ExtendedAttributeQuery eaQuery,
HashAttribute hashAttribute, @Named("pending") List<Path> pendingPaths); @Override void onMessage(ClientMessage message); boolean processFile(Path path); @Override void stop(); @Override String toString(); } |
@Test public void testToString() throws Exception { assertThat(cut.toString(), is("StorageNode")); } | @Override public String toString() { return StorageNode.class.getSimpleName(); } | StorageNode implements MessageHandler, Node { @Override public String toString() { return StorageNode.class.getSimpleName(); } } | StorageNode implements MessageHandler, Node { @Override public String toString() { return StorageNode.class.getSimpleName(); } StorageNode(ClientSession session, ExtendedAttributeQuery eaQuery, HashAttribute hashAttribute, List<Path> pendingPaths,
String resizeAddress, String eaUpdateAddress); @Inject StorageNode(@Named("normal") ClientSession session, ExtendedAttributeQuery eaQuery,
HashAttribute hashAttribute, @Named("pending") List<Path> pendingPaths); } | StorageNode implements MessageHandler, Node { @Override public String toString() { return StorageNode.class.getSimpleName(); } StorageNode(ClientSession session, ExtendedAttributeQuery eaQuery, HashAttribute hashAttribute, List<Path> pendingPaths,
String resizeAddress, String eaUpdateAddress); @Inject StorageNode(@Named("normal") ClientSession session, ExtendedAttributeQuery eaQuery,
HashAttribute hashAttribute, @Named("pending") List<Path> pendingPaths); @Override void onMessage(ClientMessage message); boolean processFile(Path path); @Override void stop(); @Override String toString(); } | StorageNode implements MessageHandler, Node { @Override public String toString() { return StorageNode.class.getSimpleName(); } StorageNode(ClientSession session, ExtendedAttributeQuery eaQuery, HashAttribute hashAttribute, List<Path> pendingPaths,
String resizeAddress, String eaUpdateAddress); @Inject StorageNode(@Named("normal") ClientSession session, ExtendedAttributeQuery eaQuery,
HashAttribute hashAttribute, @Named("pending") List<Path> pendingPaths); @Override void onMessage(ClientMessage message); boolean processFile(Path path); @Override void stop(); @Override String toString(); } |
@Test public void testReadAllDataByteRead() throws Exception { byte[] read = new byte[BUFFER_CAPACITY *2]; int actualRead = input.read(read); assertThat(actualRead, is(TEST_DATA.length)); } | @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } | ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } } | ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } ByteBufferInputstream(ByteBuffer buffer); } | ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } ByteBufferInputstream(ByteBuffer buffer); @Override int read(); @Override int available(); } | ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } ByteBufferInputstream(ByteBuffer buffer); @Override int read(); @Override int available(); } |
@Test public void testAvailable() throws Exception { assertThat(input.available(), is(TEST_DATA.length)); } | @Override public int available() throws IOException { return buffer.remaining(); } | ByteBufferInputstream extends InputStream { @Override public int available() throws IOException { return buffer.remaining(); } } | ByteBufferInputstream extends InputStream { @Override public int available() throws IOException { return buffer.remaining(); } ByteBufferInputstream(ByteBuffer buffer); } | ByteBufferInputstream extends InputStream { @Override public int available() throws IOException { return buffer.remaining(); } ByteBufferInputstream(ByteBuffer buffer); @Override int read(); @Override int available(); } | ByteBufferInputstream extends InputStream { @Override public int available() throws IOException { return buffer.remaining(); } ByteBufferInputstream(ByteBuffer buffer); @Override int read(); @Override int available(); } |
@Test public void testReadAllDataBuffered() throws Exception { byte[] read = new byte[TEST_DATA.length]; BufferedInputStream bis = new BufferedInputStream(input); bis.read(read); assertThat(read, is(TEST_DATA)); } | @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } | ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } } | ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } ByteBufferInputstream(ByteBuffer buffer); } | ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } ByteBufferInputstream(ByteBuffer buffer); @Override int read(); @Override int available(); } | ByteBufferInputstream extends InputStream { @Override public int read() throws IOException { if (buffer.hasRemaining()) { return buffer.get() & 0xFF; } else { return -1; } } ByteBufferInputstream(ByteBuffer buffer); @Override int read(); @Override int available(); } |
@Test public void testJpg() throws Exception { assertThat(cut.accept(createFile("foo.jpg")), is(true)); } | @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); @Override boolean accept(Path entry); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); @Override boolean accept(Path entry); } |
@Test public void testJpeg() throws Exception { assertThat(cut.accept(createFile("foo.jpeg")), is(true)); } | @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); @Override boolean accept(Path entry); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); @Override boolean accept(Path entry); } |
@Test public void testPng() throws Exception { assertThat(cut.accept(createFile("foo.png")), is(true)); } | @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); @Override boolean accept(Path entry); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); @Override boolean accept(Path entry); } |
@Test public void testLoadImageJpg() throws Exception { BufferedImage image = ImageUtil.loadImage(jpgPath); assertThat(image.getHeight(), is(IMAGE_SIZE)); assertThat(image.getWidth(), is(IMAGE_SIZE)); } | public static BufferedImage loadImage(Path path) throws IOException { try (InputStream is = new BufferedInputStream(Files.newInputStream(path))) { BufferedImage bi; try { bi = ImageIO.read(is); } catch (ArrayIndexOutOfBoundsException e) { bi = GifDecoder.read(is).getFrame(0); } return bi; } } | ImageUtil { public static BufferedImage loadImage(Path path) throws IOException { try (InputStream is = new BufferedInputStream(Files.newInputStream(path))) { BufferedImage bi; try { bi = ImageIO.read(is); } catch (ArrayIndexOutOfBoundsException e) { bi = GifDecoder.read(is).getFrame(0); } return bi; } } } | ImageUtil { public static BufferedImage loadImage(Path path) throws IOException { try (InputStream is = new BufferedInputStream(Files.newInputStream(path))) { BufferedImage bi; try { bi = ImageIO.read(is); } catch (ArrayIndexOutOfBoundsException e) { bi = GifDecoder.read(is).getFrame(0); } return bi; } } } | ImageUtil { public static BufferedImage loadImage(Path path) throws IOException { try (InputStream is = new BufferedInputStream(Files.newInputStream(path))) { BufferedImage bi; try { bi = ImageIO.read(is); } catch (ArrayIndexOutOfBoundsException e) { bi = GifDecoder.read(is).getFrame(0); } return bi; } } static BufferedImage bytesToImage(byte[] data); static byte[] imageToBytes(BufferedImage image); static BufferedImage loadImage(Path path); } | ImageUtil { public static BufferedImage loadImage(Path path) throws IOException { try (InputStream is = new BufferedInputStream(Files.newInputStream(path))) { BufferedImage bi; try { bi = ImageIO.read(is); } catch (ArrayIndexOutOfBoundsException e) { bi = GifDecoder.read(is).getFrame(0); } return bi; } } static BufferedImage bytesToImage(byte[] data); static byte[] imageToBytes(BufferedImage image); static BufferedImage loadImage(Path path); } |
@Test public void testGif() throws Exception { assertThat(cut.accept(createFile("foo.gif")), is(true)); } | @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); @Override boolean accept(Path entry); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); @Override boolean accept(Path entry); } |
@Test public void testNonLowerCase() throws Exception { assertThat(cut.accept(createFile("foo.Jpg")), is(true)); } | @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); @Override boolean accept(Path entry); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); @Override boolean accept(Path entry); } |
@Test public void testNonImageExtension() throws Exception { assertThat(cut.accept(createFile("foo.txt")), is(false)); } | @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); @Override boolean accept(Path entry); } | ImageFileFilter implements Filter<Path> { @Override public boolean accept(Path entry) throws IOException { return extFilter.accept(entry); } ImageFileFilter(); @Override boolean accept(Path entry); } |
@Test public void testIncrementFailedFilesEvent() throws Exception { cut.incrementFailedFiles(); verify(listener).statisticsChangedEvent(eq(StatisticsEvent.FAILED_FILES), eq(1)); } | public void incrementFailedFiles() { dispatchEvent(StatisticsEvent.FAILED_FILES, failedFiles.incrementAndGet()); } | Statistics { public void incrementFailedFiles() { dispatchEvent(StatisticsEvent.FAILED_FILES, failedFiles.incrementAndGet()); } } | Statistics { public void incrementFailedFiles() { dispatchEvent(StatisticsEvent.FAILED_FILES, failedFiles.incrementAndGet()); } } | Statistics { public void incrementFailedFiles() { dispatchEvent(StatisticsEvent.FAILED_FILES, failedFiles.incrementAndGet()); } int getFoundFiles(); void incrementFoundFiles(); int getProcessedFiles(); void incrementProcessedFiles(); int getFailedFiles(); void incrementFailedFiles(); int getSkippedFiles(); void incrementSkippedFiles(); void reset(); void addStatisticsListener(StatisticsChangedListener listener); void removeStatisticsListener(StatisticsChangedListener listener); } | Statistics { public void incrementFailedFiles() { dispatchEvent(StatisticsEvent.FAILED_FILES, failedFiles.incrementAndGet()); } int getFoundFiles(); void incrementFoundFiles(); int getProcessedFiles(); void incrementProcessedFiles(); int getFailedFiles(); void incrementFailedFiles(); int getSkippedFiles(); void incrementSkippedFiles(); void reset(); void addStatisticsListener(StatisticsChangedListener listener); void removeStatisticsListener(StatisticsChangedListener listener); } |
@Test public void testIncrementFoundFilesEvent() throws Exception { cut.incrementFoundFiles(); verify(listener).statisticsChangedEvent(eq(StatisticsEvent.FOUND_FILES), eq(1)); } | public void incrementFoundFiles() { dispatchEvent(StatisticsEvent.FOUND_FILES, foundFiles.incrementAndGet()); } | Statistics { public void incrementFoundFiles() { dispatchEvent(StatisticsEvent.FOUND_FILES, foundFiles.incrementAndGet()); } } | Statistics { public void incrementFoundFiles() { dispatchEvent(StatisticsEvent.FOUND_FILES, foundFiles.incrementAndGet()); } } | Statistics { public void incrementFoundFiles() { dispatchEvent(StatisticsEvent.FOUND_FILES, foundFiles.incrementAndGet()); } int getFoundFiles(); void incrementFoundFiles(); int getProcessedFiles(); void incrementProcessedFiles(); int getFailedFiles(); void incrementFailedFiles(); int getSkippedFiles(); void incrementSkippedFiles(); void reset(); void addStatisticsListener(StatisticsChangedListener listener); void removeStatisticsListener(StatisticsChangedListener listener); } | Statistics { public void incrementFoundFiles() { dispatchEvent(StatisticsEvent.FOUND_FILES, foundFiles.incrementAndGet()); } int getFoundFiles(); void incrementFoundFiles(); int getProcessedFiles(); void incrementProcessedFiles(); int getFailedFiles(); void incrementFailedFiles(); int getSkippedFiles(); void incrementSkippedFiles(); void reset(); void addStatisticsListener(StatisticsChangedListener listener); void removeStatisticsListener(StatisticsChangedListener listener); } |
@Test public void testIncrementProcessedFilesFiles() throws Exception { cut.incrementProcessedFiles(); verify(listener).statisticsChangedEvent(eq(StatisticsEvent.PROCESSED_FILES), eq(1)); } | public void incrementProcessedFiles() { dispatchEvent(StatisticsEvent.PROCESSED_FILES, processedFiles.incrementAndGet()); } | Statistics { public void incrementProcessedFiles() { dispatchEvent(StatisticsEvent.PROCESSED_FILES, processedFiles.incrementAndGet()); } } | Statistics { public void incrementProcessedFiles() { dispatchEvent(StatisticsEvent.PROCESSED_FILES, processedFiles.incrementAndGet()); } } | Statistics { public void incrementProcessedFiles() { dispatchEvent(StatisticsEvent.PROCESSED_FILES, processedFiles.incrementAndGet()); } int getFoundFiles(); void incrementFoundFiles(); int getProcessedFiles(); void incrementProcessedFiles(); int getFailedFiles(); void incrementFailedFiles(); int getSkippedFiles(); void incrementSkippedFiles(); void reset(); void addStatisticsListener(StatisticsChangedListener listener); void removeStatisticsListener(StatisticsChangedListener listener); } | Statistics { public void incrementProcessedFiles() { dispatchEvent(StatisticsEvent.PROCESSED_FILES, processedFiles.incrementAndGet()); } int getFoundFiles(); void incrementFoundFiles(); int getProcessedFiles(); void incrementProcessedFiles(); int getFailedFiles(); void incrementFailedFiles(); int getSkippedFiles(); void incrementSkippedFiles(); void reset(); void addStatisticsListener(StatisticsChangedListener listener); void removeStatisticsListener(StatisticsChangedListener listener); } |
@Test public void testIncrementSkippedFilesEvent() throws Exception { cut.incrementSkippedFiles(); verify(listener).statisticsChangedEvent(eq(StatisticsEvent.SKIPPED_FILES), eq(1)); } | public void incrementSkippedFiles() { dispatchEvent(StatisticsEvent.SKIPPED_FILES, skippedFiles.incrementAndGet()); } | Statistics { public void incrementSkippedFiles() { dispatchEvent(StatisticsEvent.SKIPPED_FILES, skippedFiles.incrementAndGet()); } } | Statistics { public void incrementSkippedFiles() { dispatchEvent(StatisticsEvent.SKIPPED_FILES, skippedFiles.incrementAndGet()); } } | Statistics { public void incrementSkippedFiles() { dispatchEvent(StatisticsEvent.SKIPPED_FILES, skippedFiles.incrementAndGet()); } int getFoundFiles(); void incrementFoundFiles(); int getProcessedFiles(); void incrementProcessedFiles(); int getFailedFiles(); void incrementFailedFiles(); int getSkippedFiles(); void incrementSkippedFiles(); void reset(); void addStatisticsListener(StatisticsChangedListener listener); void removeStatisticsListener(StatisticsChangedListener listener); } | Statistics { public void incrementSkippedFiles() { dispatchEvent(StatisticsEvent.SKIPPED_FILES, skippedFiles.incrementAndGet()); } int getFoundFiles(); void incrementFoundFiles(); int getProcessedFiles(); void incrementProcessedFiles(); int getFailedFiles(); void incrementFailedFiles(); int getSkippedFiles(); void incrementSkippedFiles(); void reset(); void addStatisticsListener(StatisticsChangedListener listener); void removeStatisticsListener(StatisticsChangedListener listener); } |
@Test public void testRemoveStatisticsListener() throws Exception { cut.removeStatisticsListener(listener); cut.incrementFailedFiles(); cut.incrementFoundFiles(); cut.incrementProcessedFiles(); cut.incrementSkippedFiles(); verifyZeroInteractions(listener); } | public void removeStatisticsListener(StatisticsChangedListener listener) { statisticsChangedListners.remove(listener); } | Statistics { public void removeStatisticsListener(StatisticsChangedListener listener) { statisticsChangedListners.remove(listener); } } | Statistics { public void removeStatisticsListener(StatisticsChangedListener listener) { statisticsChangedListners.remove(listener); } } | Statistics { public void removeStatisticsListener(StatisticsChangedListener listener) { statisticsChangedListners.remove(listener); } int getFoundFiles(); void incrementFoundFiles(); int getProcessedFiles(); void incrementProcessedFiles(); int getFailedFiles(); void incrementFailedFiles(); int getSkippedFiles(); void incrementSkippedFiles(); void reset(); void addStatisticsListener(StatisticsChangedListener listener); void removeStatisticsListener(StatisticsChangedListener listener); } | Statistics { public void removeStatisticsListener(StatisticsChangedListener listener) { statisticsChangedListners.remove(listener); } int getFoundFiles(); void incrementFoundFiles(); int getProcessedFiles(); void incrementProcessedFiles(); int getFailedFiles(); void incrementFailedFiles(); int getSkippedFiles(); void incrementSkippedFiles(); void reset(); void addStatisticsListener(StatisticsChangedListener listener); void removeStatisticsListener(StatisticsChangedListener listener); } |
@Test public void testRemoveViaGroup() throws Exception { Result result = new Result(groupB, recordC); assertThat(groupB.getResults(), hasItem(result)); groupA.remove(result); assertThat(groupB.getResults(), not(hasItem(result))); } | public void remove(Result result) { Collection<ResultGroup> groupsToRemoveFrom = resultsToGroups.removeAll(result); LOGGER.debug("Removing {} from {} group(s).", result, groupsToRemoveFrom.size()); for (ResultGroup g : groupsToRemoveFrom) { g.remove(result, false); checkAndremoveEmptyGroup(g); } } | GroupList { public void remove(Result result) { Collection<ResultGroup> groupsToRemoveFrom = resultsToGroups.removeAll(result); LOGGER.debug("Removing {} from {} group(s).", result, groupsToRemoveFrom.size()); for (ResultGroup g : groupsToRemoveFrom) { g.remove(result, false); checkAndremoveEmptyGroup(g); } } } | GroupList { public void remove(Result result) { Collection<ResultGroup> groupsToRemoveFrom = resultsToGroups.removeAll(result); LOGGER.debug("Removing {} from {} group(s).", result, groupsToRemoveFrom.size()); for (ResultGroup g : groupsToRemoveFrom) { g.remove(result, false); checkAndremoveEmptyGroup(g); } } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); } | GroupList { public void remove(Result result) { Collection<ResultGroup> groupsToRemoveFrom = resultsToGroups.removeAll(result); LOGGER.debug("Removing {} from {} group(s).", result, groupsToRemoveFrom.size()); for (ResultGroup g : groupsToRemoveFrom) { g.remove(result, false); checkAndremoveEmptyGroup(g); } } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } | GroupList { public void remove(Result result) { Collection<ResultGroup> groupsToRemoveFrom = resultsToGroups.removeAll(result); LOGGER.debug("Removing {} from {} group(s).", result, groupsToRemoveFrom.size()); for (ResultGroup g : groupsToRemoveFrom) { g.remove(result, false); checkAndremoveEmptyGroup(g); } } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } |
@Test public void testGroupCount() throws Exception { assertThat(cut.groupCount(), is(2)); } | public int groupCount() { return groups.size(); } | GroupList { public int groupCount() { return groups.size(); } } | GroupList { public int groupCount() { return groups.size(); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); } | GroupList { public int groupCount() { return groups.size(); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } | GroupList { public int groupCount() { return groups.size(); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } |
@Test public void testLoadImageGif() throws Exception { BufferedImage image = ImageUtil.loadImage(gifPath); assertThat(image.getHeight(), is(IMAGE_SIZE)); assertThat(image.getWidth(), is(IMAGE_SIZE)); } | public static BufferedImage loadImage(Path path) throws IOException { try (InputStream is = new BufferedInputStream(Files.newInputStream(path))) { BufferedImage bi; try { bi = ImageIO.read(is); } catch (ArrayIndexOutOfBoundsException e) { bi = GifDecoder.read(is).getFrame(0); } return bi; } } | ImageUtil { public static BufferedImage loadImage(Path path) throws IOException { try (InputStream is = new BufferedInputStream(Files.newInputStream(path))) { BufferedImage bi; try { bi = ImageIO.read(is); } catch (ArrayIndexOutOfBoundsException e) { bi = GifDecoder.read(is).getFrame(0); } return bi; } } } | ImageUtil { public static BufferedImage loadImage(Path path) throws IOException { try (InputStream is = new BufferedInputStream(Files.newInputStream(path))) { BufferedImage bi; try { bi = ImageIO.read(is); } catch (ArrayIndexOutOfBoundsException e) { bi = GifDecoder.read(is).getFrame(0); } return bi; } } } | ImageUtil { public static BufferedImage loadImage(Path path) throws IOException { try (InputStream is = new BufferedInputStream(Files.newInputStream(path))) { BufferedImage bi; try { bi = ImageIO.read(is); } catch (ArrayIndexOutOfBoundsException e) { bi = GifDecoder.read(is).getFrame(0); } return bi; } } static BufferedImage bytesToImage(byte[] data); static byte[] imageToBytes(BufferedImage image); static BufferedImage loadImage(Path path); } | ImageUtil { public static BufferedImage loadImage(Path path) throws IOException { try (InputStream is = new BufferedInputStream(Files.newInputStream(path))) { BufferedImage bi; try { bi = ImageIO.read(is); } catch (ArrayIndexOutOfBoundsException e) { bi = GifDecoder.read(is).getFrame(0); } return bi; } } static BufferedImage bytesToImage(byte[] data); static byte[] imageToBytes(BufferedImage image); static BufferedImage loadImage(Path path); } |
@Test public void testGetGroup() throws Exception { assertThat(cut.getGroup(HASH_A), is(groupA)); } | public ResultGroup getGroup(long hash) throws IllegalArgumentException { ResultGroup group = hashToGroup.get(hash); if (group == null) { throw new IllegalArgumentException("Query for unknown hash"); } return group; } | GroupList { public ResultGroup getGroup(long hash) throws IllegalArgumentException { ResultGroup group = hashToGroup.get(hash); if (group == null) { throw new IllegalArgumentException("Query for unknown hash"); } return group; } } | GroupList { public ResultGroup getGroup(long hash) throws IllegalArgumentException { ResultGroup group = hashToGroup.get(hash); if (group == null) { throw new IllegalArgumentException("Query for unknown hash"); } return group; } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); } | GroupList { public ResultGroup getGroup(long hash) throws IllegalArgumentException { ResultGroup group = hashToGroup.get(hash); if (group == null) { throw new IllegalArgumentException("Query for unknown hash"); } return group; } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } | GroupList { public ResultGroup getGroup(long hash) throws IllegalArgumentException { ResultGroup group = hashToGroup.get(hash); if (group == null) { throw new IllegalArgumentException("Query for unknown hash"); } return group; } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } |
@Test(expected = IllegalArgumentException.class) public void testGetInvalidHash() throws Exception { cut.getGroup(-1); } | public ResultGroup getGroup(long hash) throws IllegalArgumentException { ResultGroup group = hashToGroup.get(hash); if (group == null) { throw new IllegalArgumentException("Query for unknown hash"); } return group; } | GroupList { public ResultGroup getGroup(long hash) throws IllegalArgumentException { ResultGroup group = hashToGroup.get(hash); if (group == null) { throw new IllegalArgumentException("Query for unknown hash"); } return group; } } | GroupList { public ResultGroup getGroup(long hash) throws IllegalArgumentException { ResultGroup group = hashToGroup.get(hash); if (group == null) { throw new IllegalArgumentException("Query for unknown hash"); } return group; } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); } | GroupList { public ResultGroup getGroup(long hash) throws IllegalArgumentException { ResultGroup group = hashToGroup.get(hash); if (group == null) { throw new IllegalArgumentException("Query for unknown hash"); } return group; } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } | GroupList { public ResultGroup getGroup(long hash) throws IllegalArgumentException { ResultGroup group = hashToGroup.get(hash); if (group == null) { throw new IllegalArgumentException("Query for unknown hash"); } return group; } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } |
@Test public void testEmptyGroupRemovedFromGui() throws Exception { cut = new GroupList(dlm); initGroupList(); groupA.remove(new Result(groupA, recordC)); groupA.remove(new Result(groupA, recordA)); assertThat(dlm.contains(groupA), is(false)); } | public void remove(Result result) { Collection<ResultGroup> groupsToRemoveFrom = resultsToGroups.removeAll(result); LOGGER.debug("Removing {} from {} group(s).", result, groupsToRemoveFrom.size()); for (ResultGroup g : groupsToRemoveFrom) { g.remove(result, false); checkAndremoveEmptyGroup(g); } } | GroupList { public void remove(Result result) { Collection<ResultGroup> groupsToRemoveFrom = resultsToGroups.removeAll(result); LOGGER.debug("Removing {} from {} group(s).", result, groupsToRemoveFrom.size()); for (ResultGroup g : groupsToRemoveFrom) { g.remove(result, false); checkAndremoveEmptyGroup(g); } } } | GroupList { public void remove(Result result) { Collection<ResultGroup> groupsToRemoveFrom = resultsToGroups.removeAll(result); LOGGER.debug("Removing {} from {} group(s).", result, groupsToRemoveFrom.size()); for (ResultGroup g : groupsToRemoveFrom) { g.remove(result, false); checkAndremoveEmptyGroup(g); } } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); } | GroupList { public void remove(Result result) { Collection<ResultGroup> groupsToRemoveFrom = resultsToGroups.removeAll(result); LOGGER.debug("Removing {} from {} group(s).", result, groupsToRemoveFrom.size()); for (ResultGroup g : groupsToRemoveFrom) { g.remove(result, false); checkAndremoveEmptyGroup(g); } } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } | GroupList { public void remove(Result result) { Collection<ResultGroup> groupsToRemoveFrom = resultsToGroups.removeAll(result); LOGGER.debug("Removing {} from {} group(s).", result, groupsToRemoveFrom.size()); for (ResultGroup g : groupsToRemoveFrom) { g.remove(result, false); checkAndremoveEmptyGroup(g); } } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } |
@Test public void testPreviousGroup() throws Exception { assertThat(cut.previousGroup(groupB), is(groupA)); } | public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } | GroupList { public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } } | GroupList { public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); } | GroupList { public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } | GroupList { public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } |
@Test public void testPreviousGroupWithFirstGroup() throws Exception { assertThat(cut.previousGroup(groupA), is(groupA)); } | public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } | GroupList { public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } } | GroupList { public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); } | GroupList { public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } | GroupList { public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } |
@Test public void testPreviousGroupWithUnknownGroup() throws Exception { assertThat(cut.previousGroup(groupUnknown), is(groupA)); } | public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } | GroupList { public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } } | GroupList { public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); } | GroupList { public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } | GroupList { public ResultGroup previousGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(--index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } |
@Test public void testNextGroup() throws Exception { assertThat(cut.nextGroup(groupA), is(groupB)); } | public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } | GroupList { public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } } | GroupList { public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); } | GroupList { public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } | GroupList { public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } |
@Test public void testNextGroupWithLastGroup() throws Exception { assertThat(cut.nextGroup(groupB), is(groupB)); } | public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } | GroupList { public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } } | GroupList { public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); } | GroupList { public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } | GroupList { public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } |
@Test public void testNextGroupWithUnknownGroup() throws Exception { assertThat(cut.nextGroup(groupUnknown), is(groupA)); } | public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } | GroupList { public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } } | GroupList { public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); } | GroupList { public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } | GroupList { public ResultGroup nextGroup(ResultGroup currentGroup) { int index = groups.indexOf(currentGroup); index = boundsCheckedIndex(++index); return groups.get(index); } GroupList(); GroupList(DefaultListModel<ResultGroup> mappedListModel); void populateList(Collection<ResultGroup> groupsToAdd); int groupCount(); void remove(Result result); ResultGroup getGroup(long hash); List<ResultGroup> getAllGroups(); void setMappedListModel(DefaultListModel<ResultGroup> mappedListeModel); ResultGroup nextGroup(ResultGroup currentGroup); ResultGroup previousGroup(ResultGroup currentGroup); } |
@Test public void testGetImageRecord() throws Exception { assertThat(cut.getImageRecord(), is(imageRecord)); } | public ImageRecord getImageRecord() { return imageRecord; } | Result { public ImageRecord getImageRecord() { return imageRecord; } } | Result { public ImageRecord getImageRecord() { return imageRecord; } Result(ResultGroup parentGroup, ImageRecord imageRecord); } | Result { public ImageRecord getImageRecord() { return imageRecord; } Result(ResultGroup parentGroup, ImageRecord imageRecord); ImageRecord getImageRecord(); void remove(); @Override String toString(); @Override final int hashCode(); @Override final boolean equals(Object obj); } | Result { public ImageRecord getImageRecord() { return imageRecord; } Result(ResultGroup parentGroup, ImageRecord imageRecord); ImageRecord getImageRecord(); void remove(); @Override String toString(); @Override final int hashCode(); @Override final boolean equals(Object obj); } |
@Test public void testSanitizeTag() throws Exception { assertThat(StringUtil.sanitizeTag(TEST_TAG), is(TEST_TAG)); } | public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } | StringUtil { public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } } | StringUtil { public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } private StringUtil(); } | StringUtil { public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } private StringUtil(); static String sanitizeTag(String tagFromGui); } | StringUtil { public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } private StringUtil(); static String sanitizeTag(String tagFromGui); static final String MATCH_ALL_TAGS; } |
@Test public void testRemoveResult() throws Exception { cut.remove(); verify(parentGroup).remove(cut); } | public void remove() { LOGGER.debug("Removing result {}", this); parentGroup.remove(this); } | Result { public void remove() { LOGGER.debug("Removing result {}", this); parentGroup.remove(this); } } | Result { public void remove() { LOGGER.debug("Removing result {}", this); parentGroup.remove(this); } Result(ResultGroup parentGroup, ImageRecord imageRecord); } | Result { public void remove() { LOGGER.debug("Removing result {}", this); parentGroup.remove(this); } Result(ResultGroup parentGroup, ImageRecord imageRecord); ImageRecord getImageRecord(); void remove(); @Override String toString(); @Override final int hashCode(); @Override final boolean equals(Object obj); } | Result { public void remove() { LOGGER.debug("Removing result {}", this); parentGroup.remove(this); } Result(ResultGroup parentGroup, ImageRecord imageRecord); ImageRecord getImageRecord(); void remove(); @Override String toString(); @Override final int hashCode(); @Override final boolean equals(Object obj); } |
@Test public void testGetHash() throws Exception { assertThat(cut.getHash(), is(HASH)); } | public long getHash() { return hash; } | ResultGroup { public long getHash() { return hash; } } | ResultGroup { public long getHash() { return hash; } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); } | ResultGroup { public long getHash() { return hash; } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } | ResultGroup { public long getHash() { return hash; } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } |
@Test public void testGetResults() throws Exception { assertThat(cut.getResults(), hasItems(resultA, new Result(cut, recordB))); } | public List<Result> getResults() { return results; } | ResultGroup { public List<Result> getResults() { return results; } } | ResultGroup { public List<Result> getResults() { return results; } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); } | ResultGroup { public List<Result> getResults() { return results; } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } | ResultGroup { public List<Result> getResults() { return results; } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } |
@Test public void testRemove() throws Exception { assertThat(cut.remove(resultA), is(true)); } | public boolean remove(Result result) { return remove(result, true); } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } |
@Test public void testRemoveNonExistingResult() throws Exception { cut.remove(resultA); assertThat(cut.remove(resultA), is(false)); } | public boolean remove(Result result) { return remove(result, true); } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } |
@Test public void testNotifyParentOnResultRemoval() throws Exception { cut.remove(resultA); verify(parent).remove(resultA); } | public boolean remove(Result result) { return remove(result, true); } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } |
@Test public void testRemoveWithoutNotification() throws Exception { cut.remove(resultA, false); verify(parent, never()).remove(resultA); } | public boolean remove(Result result) { return remove(result, true); } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } | ResultGroup { public boolean remove(Result result) { return remove(result, true); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } |
@Test public void testHasResults() throws Exception { assertThat(cut.hasResults(), is(true)); } | public boolean hasResults() { return !results.isEmpty(); } | ResultGroup { public boolean hasResults() { return !results.isEmpty(); } } | ResultGroup { public boolean hasResults() { return !results.isEmpty(); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); } | ResultGroup { public boolean hasResults() { return !results.isEmpty(); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } | ResultGroup { public boolean hasResults() { return !results.isEmpty(); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } |
@Test public void testToString() throws Exception { assertThat(cut.toString(), is("42 (2)")); } | @Override public String toString() { return String.format("%d (%d)", this.hash, results.size()); } | ResultGroup { @Override public String toString() { return String.format("%d (%d)", this.hash, results.size()); } } | ResultGroup { @Override public String toString() { return String.format("%d (%d)", this.hash, results.size()); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); } | ResultGroup { @Override public String toString() { return String.format("%d (%d)", this.hash, results.size()); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } | ResultGroup { @Override public String toString() { return String.format("%d (%d)", this.hash, results.size()); } ResultGroup(GroupList parent, long hash, Collection<ImageRecord> records); long getHash(); List<Result> getResults(); boolean remove(Result result); boolean remove(Result result, boolean notifyParent); @Override String toString(); boolean hasResults(); @Override final int hashCode(); @Override final boolean equals(Object obj); } |
@Test public void testGetPath() throws Exception { assertThat(imageRecord.getPath(), is("foo")); } | public String getPath() { return path; } | ImageRecord implements Comparable<ImageRecord> { public String getPath() { return path; } } | ImageRecord implements Comparable<ImageRecord> { public String getPath() { return path; } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); } | ImageRecord implements Comparable<ImageRecord> { public String getPath() { return path; } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); } | ImageRecord implements Comparable<ImageRecord> { public String getPath() { return path; } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); static final String PATH_COLUMN_NAME; } |
@Test public void testSanitizeTagNull() throws Exception { assertThat(StringUtil.sanitizeTag(null), is(StringUtil.MATCH_ALL_TAGS)); } | public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } | StringUtil { public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } } | StringUtil { public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } private StringUtil(); } | StringUtil { public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } private StringUtil(); static String sanitizeTag(String tagFromGui); } | StringUtil { public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } private StringUtil(); static String sanitizeTag(String tagFromGui); static final String MATCH_ALL_TAGS; } |
@Test public void testGetpHash() throws Exception { assertThat(imageRecord.getpHash(), is(42L)); } | public long getpHash() { return pHash; } | ImageRecord implements Comparable<ImageRecord> { public long getpHash() { return pHash; } } | ImageRecord implements Comparable<ImageRecord> { public long getpHash() { return pHash; } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); } | ImageRecord implements Comparable<ImageRecord> { public long getpHash() { return pHash; } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); } | ImageRecord implements Comparable<ImageRecord> { public long getpHash() { return pHash; } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); static final String PATH_COLUMN_NAME; } |
@Test public void testCompareToSelf() throws Exception { assertThat(imageRecord.compareTo(imageRecord), is(0)); } | @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); static final String PATH_COLUMN_NAME; } |
@Test(expected = NullPointerException.class) public void testCompareToNull() throws Exception { imageRecord.compareTo(null); } | @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); static final String PATH_COLUMN_NAME; } |
@Test public void testCompareToBigger() throws Exception { assertThat(imageRecord.compareTo(new ImageRecord("bar", 55)), is(-1)); } | @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); static final String PATH_COLUMN_NAME; } |
@Test public void testCompareToSmaller() throws Exception { assertThat(imageRecord.compareTo(new ImageRecord("bar", 7)), is(1)); } | @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); static final String PATH_COLUMN_NAME; } |
@Test public void testCompareToEqual() throws Exception { assertThat(imageRecord.compareTo(new ImageRecord("bar", 42)), is(0)); } | @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); } | ImageRecord implements Comparable<ImageRecord> { @Override public int compareTo(ImageRecord o) { if (o == null) { throw new NullPointerException(); } if (this.pHash == o.getpHash()) { return 0; } else if (this.getpHash() > o.pHash) { return 1; } else { return -1; } } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); static final String PATH_COLUMN_NAME; } |
@Test public void testEquals() throws Exception { EqualsVerifier.forClass(ImageRecord.class).suppress(Warning.NONFINAL_FIELDS).verify(); } | @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ImageRecord other = (ImageRecord) obj; if (pHash != other.pHash) return false; if (path == null) { if (other.path != null) return false; } else if (!path.equals(other.path)) return false; return true; } | ImageRecord implements Comparable<ImageRecord> { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ImageRecord other = (ImageRecord) obj; if (pHash != other.pHash) return false; if (path == null) { if (other.path != null) return false; } else if (!path.equals(other.path)) return false; return true; } } | ImageRecord implements Comparable<ImageRecord> { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ImageRecord other = (ImageRecord) obj; if (pHash != other.pHash) return false; if (path == null) { if (other.path != null) return false; } else if (!path.equals(other.path)) return false; return true; } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); } | ImageRecord implements Comparable<ImageRecord> { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ImageRecord other = (ImageRecord) obj; if (pHash != other.pHash) return false; if (path == null) { if (other.path != null) return false; } else if (!path.equals(other.path)) return false; return true; } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); } | ImageRecord implements Comparable<ImageRecord> { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ImageRecord other = (ImageRecord) obj; if (pHash != other.pHash) return false; if (path == null) { if (other.path != null) return false; } else if (!path.equals(other.path)) return false; return true; } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); static final String PATH_COLUMN_NAME; } |
@Test public void testToString() throws Exception { assertThat(imageRecord.toString(), is(EXPECTED_TO_STRING)); } | @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("ImageRecord"); sb.append("{"); sb.append("path:"); sb.append(path); sb.append(","); sb.append("hash:"); sb.append(pHash); sb.append("}"); return sb.toString(); } | ImageRecord implements Comparable<ImageRecord> { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("ImageRecord"); sb.append("{"); sb.append("path:"); sb.append(path); sb.append(","); sb.append("hash:"); sb.append(pHash); sb.append("}"); return sb.toString(); } } | ImageRecord implements Comparable<ImageRecord> { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("ImageRecord"); sb.append("{"); sb.append("path:"); sb.append(path); sb.append(","); sb.append("hash:"); sb.append(pHash); sb.append("}"); return sb.toString(); } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); } | ImageRecord implements Comparable<ImageRecord> { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("ImageRecord"); sb.append("{"); sb.append("path:"); sb.append(path); sb.append(","); sb.append("hash:"); sb.append(pHash); sb.append("}"); return sb.toString(); } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); } | ImageRecord implements Comparable<ImageRecord> { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("ImageRecord"); sb.append("{"); sb.append("path:"); sb.append(path); sb.append(","); sb.append("hash:"); sb.append(pHash); sb.append("}"); return sb.toString(); } @Deprecated ImageRecord(); ImageRecord(String path, long pHash); String getPath(); long getpHash(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(ImageRecord o); @Override String toString(); static final String PATH_COLUMN_NAME; } |
@Test public void testGetPath() throws Exception { assertThat(badFileRecord.getPath(), is("bad")); } | public String getPath() { return path; } | BadFileRecord { public String getPath() { return path; } } | BadFileRecord { public String getPath() { return path; } @Deprecated BadFileRecord(); BadFileRecord(Path path); } | BadFileRecord { public String getPath() { return path; } @Deprecated BadFileRecord(); BadFileRecord(Path path); String getPath(); } | BadFileRecord { public String getPath() { return path; } @Deprecated BadFileRecord(); BadFileRecord(Path path); String getPath(); } |
@Test public void testRepositoryExceptionStringThrowableMessage() throws Exception { cut = new RepositoryException(TEST_MESSAGE, testException); assertThat(cut.getMessage(), is(TEST_MESSAGE)); } | public final String getMessage() { return message; } | RepositoryException extends Exception { public final String getMessage() { return message; } } | RepositoryException extends Exception { public final String getMessage() { return message; } RepositoryException(String message, Throwable cause); RepositoryException(String message); } | RepositoryException extends Exception { public final String getMessage() { return message; } RepositoryException(String message, Throwable cause); RepositoryException(String message); final String getMessage(); final Throwable getCause(); } | RepositoryException extends Exception { public final String getMessage() { return message; } RepositoryException(String message, Throwable cause); RepositoryException(String message); final String getMessage(); final Throwable getCause(); } |
@Test public void testSanitizeTagEmpty() throws Exception { assertThat(StringUtil.sanitizeTag(""), is(StringUtil.MATCH_ALL_TAGS)); } | public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } | StringUtil { public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } } | StringUtil { public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } private StringUtil(); } | StringUtil { public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } private StringUtil(); static String sanitizeTag(String tagFromGui); } | StringUtil { public static String sanitizeTag(String tagFromGui) { if (tagFromGui == null || "".equals(tagFromGui)) { return MATCH_ALL_TAGS; } return tagFromGui; } private StringUtil(); static String sanitizeTag(String tagFromGui); static final String MATCH_ALL_TAGS; } |
@Test public void testRepositoryExceptionStringThrowableCause() throws Exception { cut = new RepositoryException(TEST_MESSAGE, testException); assertThat(cut.getCause(), is(testException)); } | public final Throwable getCause() { return cause; } | RepositoryException extends Exception { public final Throwable getCause() { return cause; } } | RepositoryException extends Exception { public final Throwable getCause() { return cause; } RepositoryException(String message, Throwable cause); RepositoryException(String message); } | RepositoryException extends Exception { public final Throwable getCause() { return cause; } RepositoryException(String message, Throwable cause); RepositoryException(String message); final String getMessage(); final Throwable getCause(); } | RepositoryException extends Exception { public final Throwable getCause() { return cause; } RepositoryException(String message, Throwable cause); RepositoryException(String message); final String getMessage(); final Throwable getCause(); } |
@Test public void testRepositoryExceptionStringMessage() throws Exception { cut = new RepositoryException(TEST_MESSAGE); assertThat(cut.getMessage(), is(TEST_MESSAGE)); } | public final String getMessage() { return message; } | RepositoryException extends Exception { public final String getMessage() { return message; } } | RepositoryException extends Exception { public final String getMessage() { return message; } RepositoryException(String message, Throwable cause); RepositoryException(String message); } | RepositoryException extends Exception { public final String getMessage() { return message; } RepositoryException(String message, Throwable cause); RepositoryException(String message); final String getMessage(); final Throwable getCause(); } | RepositoryException extends Exception { public final String getMessage() { return message; } RepositoryException(String message, Throwable cause); RepositoryException(String message); final String getMessage(); final Throwable getCause(); } |
@Test public void testRepositoryExceptionStringCause() throws Exception { cut = new RepositoryException(TEST_MESSAGE); assertThat(cut.getCause(), nullValue()); } | public final Throwable getCause() { return cause; } | RepositoryException extends Exception { public final Throwable getCause() { return cause; } } | RepositoryException extends Exception { public final Throwable getCause() { return cause; } RepositoryException(String message, Throwable cause); RepositoryException(String message); } | RepositoryException extends Exception { public final Throwable getCause() { return cause; } RepositoryException(String message, Throwable cause); RepositoryException(String message); final String getMessage(); final Throwable getCause(); } | RepositoryException extends Exception { public final Throwable getCause() { return cause; } RepositoryException(String message, Throwable cause); RepositoryException(String message); final String getMessage(); final Throwable getCause(); } |
@Test public void testBuildFilterRepository() throws Exception { FilterRepository fr = cut.buildFilterRepository(); fr.store(new FilterRecord(0, new Tag(TEST_STRING))); } | @Override public FilterRepository buildFilterRepository() throws RepositoryException { return new OrmliteFilterRepository(filterRecordDao, thumbnailDao); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public FilterRepository buildFilterRepository() throws RepositoryException { return new OrmliteFilterRepository(filterRecordDao, thumbnailDao); } } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public FilterRepository buildFilterRepository() throws RepositoryException { return new OrmliteFilterRepository(filterRecordDao, thumbnailDao); } @Inject OrmliteRepositoryFactory(Database database); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public FilterRepository buildFilterRepository() throws RepositoryException { return new OrmliteFilterRepository(filterRecordDao, thumbnailDao); } @Inject OrmliteRepositoryFactory(Database database); @Override FilterRepository buildFilterRepository(); @Override ImageRepository buildImageRepository(); @Override TagRepository buildTagRepository(); @Override PendingHashImageRepository buildPendingHashImageRepository(); @Override IgnoreRepository buildIgnoreRepository(); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public FilterRepository buildFilterRepository() throws RepositoryException { return new OrmliteFilterRepository(filterRecordDao, thumbnailDao); } @Inject OrmliteRepositoryFactory(Database database); @Override FilterRepository buildFilterRepository(); @Override ImageRepository buildImageRepository(); @Override TagRepository buildTagRepository(); @Override PendingHashImageRepository buildPendingHashImageRepository(); @Override IgnoreRepository buildIgnoreRepository(); } |
@Test public void testBuildImageRepository() throws Exception { ImageRepository ir = cut.buildImageRepository(); ir.store(new ImageRecord(TEST_STRING, 0)); } | @Override public ImageRepository buildImageRepository() throws RepositoryException { return new OrmliteImageRepository(imageRecordDao, ignoreDao); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public ImageRepository buildImageRepository() throws RepositoryException { return new OrmliteImageRepository(imageRecordDao, ignoreDao); } } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public ImageRepository buildImageRepository() throws RepositoryException { return new OrmliteImageRepository(imageRecordDao, ignoreDao); } @Inject OrmliteRepositoryFactory(Database database); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public ImageRepository buildImageRepository() throws RepositoryException { return new OrmliteImageRepository(imageRecordDao, ignoreDao); } @Inject OrmliteRepositoryFactory(Database database); @Override FilterRepository buildFilterRepository(); @Override ImageRepository buildImageRepository(); @Override TagRepository buildTagRepository(); @Override PendingHashImageRepository buildPendingHashImageRepository(); @Override IgnoreRepository buildIgnoreRepository(); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public ImageRepository buildImageRepository() throws RepositoryException { return new OrmliteImageRepository(imageRecordDao, ignoreDao); } @Inject OrmliteRepositoryFactory(Database database); @Override FilterRepository buildFilterRepository(); @Override ImageRepository buildImageRepository(); @Override TagRepository buildTagRepository(); @Override PendingHashImageRepository buildPendingHashImageRepository(); @Override IgnoreRepository buildIgnoreRepository(); } |
@Test public void testBuildTagRepository() throws Exception { TagRepository tr = cut.buildTagRepository(); tr.store(new Tag(TEST_STRING)); } | @Override public TagRepository buildTagRepository() throws RepositoryException { return new OrmliteTagRepository(tagDao); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public TagRepository buildTagRepository() throws RepositoryException { return new OrmliteTagRepository(tagDao); } } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public TagRepository buildTagRepository() throws RepositoryException { return new OrmliteTagRepository(tagDao); } @Inject OrmliteRepositoryFactory(Database database); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public TagRepository buildTagRepository() throws RepositoryException { return new OrmliteTagRepository(tagDao); } @Inject OrmliteRepositoryFactory(Database database); @Override FilterRepository buildFilterRepository(); @Override ImageRepository buildImageRepository(); @Override TagRepository buildTagRepository(); @Override PendingHashImageRepository buildPendingHashImageRepository(); @Override IgnoreRepository buildIgnoreRepository(); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public TagRepository buildTagRepository() throws RepositoryException { return new OrmliteTagRepository(tagDao); } @Inject OrmliteRepositoryFactory(Database database); @Override FilterRepository buildFilterRepository(); @Override ImageRepository buildImageRepository(); @Override TagRepository buildTagRepository(); @Override PendingHashImageRepository buildPendingHashImageRepository(); @Override IgnoreRepository buildIgnoreRepository(); } |
@Test public void testBuildPendingImageRepository() throws Exception { PendingHashImageRepository phir = cut.buildPendingHashImageRepository(); phir.store(new PendingHashImage(TEST_STRING, 0, 0)); } | @Override public PendingHashImageRepository buildPendingHashImageRepository() throws RepositoryException { return new OrmlitePendingHashImage(pendingDao); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public PendingHashImageRepository buildPendingHashImageRepository() throws RepositoryException { return new OrmlitePendingHashImage(pendingDao); } } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public PendingHashImageRepository buildPendingHashImageRepository() throws RepositoryException { return new OrmlitePendingHashImage(pendingDao); } @Inject OrmliteRepositoryFactory(Database database); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public PendingHashImageRepository buildPendingHashImageRepository() throws RepositoryException { return new OrmlitePendingHashImage(pendingDao); } @Inject OrmliteRepositoryFactory(Database database); @Override FilterRepository buildFilterRepository(); @Override ImageRepository buildImageRepository(); @Override TagRepository buildTagRepository(); @Override PendingHashImageRepository buildPendingHashImageRepository(); @Override IgnoreRepository buildIgnoreRepository(); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public PendingHashImageRepository buildPendingHashImageRepository() throws RepositoryException { return new OrmlitePendingHashImage(pendingDao); } @Inject OrmliteRepositoryFactory(Database database); @Override FilterRepository buildFilterRepository(); @Override ImageRepository buildImageRepository(); @Override TagRepository buildTagRepository(); @Override PendingHashImageRepository buildPendingHashImageRepository(); @Override IgnoreRepository buildIgnoreRepository(); } |
@Test public void testBuildIgnoreRepository() throws Exception { IgnoreRepository ir = cut.buildIgnoreRepository(); ir.store(new IgnoreRecord(new ImageRecord(TEST_STRING, 0))); } | @Override public IgnoreRepository buildIgnoreRepository() throws RepositoryException { return new OrmliteIgnoreRepository(ignoreDao); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public IgnoreRepository buildIgnoreRepository() throws RepositoryException { return new OrmliteIgnoreRepository(ignoreDao); } } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public IgnoreRepository buildIgnoreRepository() throws RepositoryException { return new OrmliteIgnoreRepository(ignoreDao); } @Inject OrmliteRepositoryFactory(Database database); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public IgnoreRepository buildIgnoreRepository() throws RepositoryException { return new OrmliteIgnoreRepository(ignoreDao); } @Inject OrmliteRepositoryFactory(Database database); @Override FilterRepository buildFilterRepository(); @Override ImageRepository buildImageRepository(); @Override TagRepository buildTagRepository(); @Override PendingHashImageRepository buildPendingHashImageRepository(); @Override IgnoreRepository buildIgnoreRepository(); } | OrmliteRepositoryFactory implements RepositoryFactory { @Override public IgnoreRepository buildIgnoreRepository() throws RepositoryException { return new OrmliteIgnoreRepository(ignoreDao); } @Inject OrmliteRepositoryFactory(Database database); @Override FilterRepository buildFilterRepository(); @Override ImageRepository buildImageRepository(); @Override TagRepository buildTagRepository(); @Override PendingHashImageRepository buildPendingHashImageRepository(); @Override IgnoreRepository buildIgnoreRepository(); } |
@Test public void testStoreQueryDatabase() throws Exception { cut.store(newEntry); assertThat(dao.queryForMatchingArgs(newEntry), hasSize(1)); } | @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } |
@Test public void testStoreReturnValue() throws Exception { assertThat(cut.store(newEntry), is(true)); } | @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } |
@Test public void testSupportsExtendedAttributes() throws Exception { assertThat(ExtendedAttribute.supportsExtendedAttributes(tempFile), is(true)); } | public static boolean supportsExtendedAttributes(Path path) { try { return Files.getFileStore(path).supportsFileAttributeView(UserDefinedFileAttributeView.class); } catch (IOException e) { LOGGER.debug("Failed to check extended attributes via FileStore ({}) for {}, falling back to write test...", e.toString(), path); return checkSupportWithWrite(path); } } | ExtendedAttribute implements ExtendedAttributeQuery { public static boolean supportsExtendedAttributes(Path path) { try { return Files.getFileStore(path).supportsFileAttributeView(UserDefinedFileAttributeView.class); } catch (IOException e) { LOGGER.debug("Failed to check extended attributes via FileStore ({}) for {}, falling back to write test...", e.toString(), path); return checkSupportWithWrite(path); } } } | ExtendedAttribute implements ExtendedAttributeQuery { public static boolean supportsExtendedAttributes(Path path) { try { return Files.getFileStore(path).supportsFileAttributeView(UserDefinedFileAttributeView.class); } catch (IOException e) { LOGGER.debug("Failed to check extended attributes via FileStore ({}) for {}, falling back to write test...", e.toString(), path); return checkSupportWithWrite(path); } } } | ExtendedAttribute implements ExtendedAttributeQuery { public static boolean supportsExtendedAttributes(Path path) { try { return Files.getFileStore(path).supportsFileAttributeView(UserDefinedFileAttributeView.class); } catch (IOException e) { LOGGER.debug("Failed to check extended attributes via FileStore ({}) for {}, falling back to write test...", e.toString(), path); return checkSupportWithWrite(path); } } static String createName(String... names); static boolean supportsExtendedAttributes(Path path); static void deleteExtendedAttribute(Path path, String name); static void setExtendedAttribute(Path path, String name, String value); static void setExtendedAttribute(Path path, String name, ByteBuffer value); static ByteBuffer readExtendedAttribute(Path path, String name); static String readExtendedAttributeAsString(Path path, String name); static boolean isExtendedAttributeSet(Path path, String name); @Override boolean isEaSupported(Path path); } | ExtendedAttribute implements ExtendedAttributeQuery { public static boolean supportsExtendedAttributes(Path path) { try { return Files.getFileStore(path).supportsFileAttributeView(UserDefinedFileAttributeView.class); } catch (IOException e) { LOGGER.debug("Failed to check extended attributes via FileStore ({}) for {}, falling back to write test...", e.toString(), path); return checkSupportWithWrite(path); } } static String createName(String... names); static boolean supportsExtendedAttributes(Path path); static void deleteExtendedAttribute(Path path, String name); static void setExtendedAttribute(Path path, String name, String value); static void setExtendedAttribute(Path path, String name, ByteBuffer value); static ByteBuffer readExtendedAttribute(Path path, String name); static String readExtendedAttributeAsString(Path path, String name); static boolean isExtendedAttributeSet(Path path, String name); @Override boolean isEaSupported(Path path); static final String SIMILARIMAGE_NAMESPACE; } |
@Test public void testStoreDuplicate() throws Exception { assertThat(cut.store(existingEntry), is(false)); } | @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public synchronized boolean store(PendingHashImage image) throws RepositoryException { try { if (pendingDao.queryForMatchingArgs(image).isEmpty()) { pendingDao.create(image); return true; } else { return false; } } catch (SQLException e) { throw new RepositoryException("Failed to store entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } |
@Test public void testExistsById() throws Exception { assertThat(cut.exists(existingEntry), is(true)); } | @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } |
@Test public void testExistsByPath() throws Exception { assertThat(cut.exists(new PendingHashImage(EXISTING_PATH, UUID_EXISTING)), is(true)); } | @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } |
@Test public void testExistsNotFound() throws Exception { assertThat(cut.exists(newEntry), is(false)); } | @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public boolean exists(PendingHashImage image) throws RepositoryException { try { if (pendingDao.refresh(image) == 0) { return !pendingDao.queryForMatching(image).isEmpty(); } else { return true; } } catch (SQLException e) { throw new RepositoryException("Failed to lookup entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } |
@Test public void testGetAll() throws Exception { dao.create(newEntry); assertThat(cut.getAll(), containsInAnyOrder(newEntry, existingEntry)); } | @Override public List<PendingHashImage> getAll() throws RepositoryException { try { return pendingDao.queryForAll(); } catch (SQLException e) { throw new RepositoryException("Failed to query for all entries", e); } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public List<PendingHashImage> getAll() throws RepositoryException { try { return pendingDao.queryForAll(); } catch (SQLException e) { throw new RepositoryException("Failed to query for all entries", e); } } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public List<PendingHashImage> getAll() throws RepositoryException { try { return pendingDao.queryForAll(); } catch (SQLException e) { throw new RepositoryException("Failed to query for all entries", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public List<PendingHashImage> getAll() throws RepositoryException { try { return pendingDao.queryForAll(); } catch (SQLException e) { throw new RepositoryException("Failed to query for all entries", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public List<PendingHashImage> getAll() throws RepositoryException { try { return pendingDao.queryForAll(); } catch (SQLException e) { throw new RepositoryException("Failed to query for all entries", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } |
@Test public void testGetByUuidNonExisting() throws Exception { assertThat(cut.getByUUID(UUID_NEW.getMostSignificantBits(), UUID_NEW.getLeastSignificantBits()), is(nullValue())); } | @Override public PendingHashImage getByUUID(long most, long least) throws RepositoryException { try { synchronized (uuidQuery) { mostParam.setValue(most); leastParam.setValue(least); return pendingDao.queryForFirst(uuidQuery); } } catch (SQLException e) { throw new RepositoryException("Failed to get entry by id", e); } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public PendingHashImage getByUUID(long most, long least) throws RepositoryException { try { synchronized (uuidQuery) { mostParam.setValue(most); leastParam.setValue(least); return pendingDao.queryForFirst(uuidQuery); } } catch (SQLException e) { throw new RepositoryException("Failed to get entry by id", e); } } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public PendingHashImage getByUUID(long most, long least) throws RepositoryException { try { synchronized (uuidQuery) { mostParam.setValue(most); leastParam.setValue(least); return pendingDao.queryForFirst(uuidQuery); } } catch (SQLException e) { throw new RepositoryException("Failed to get entry by id", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public PendingHashImage getByUUID(long most, long least) throws RepositoryException { try { synchronized (uuidQuery) { mostParam.setValue(most); leastParam.setValue(least); return pendingDao.queryForFirst(uuidQuery); } } catch (SQLException e) { throw new RepositoryException("Failed to get entry by id", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public PendingHashImage getByUUID(long most, long least) throws RepositoryException { try { synchronized (uuidQuery) { mostParam.setValue(most); leastParam.setValue(least); return pendingDao.queryForFirst(uuidQuery); } } catch (SQLException e) { throw new RepositoryException("Failed to get entry by id", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } |
@Test public void testGetByUuidExisting() throws Exception { assertThat(cut.getByUUID(UUID_EXISTING.getMostSignificantBits(), UUID_EXISTING.getLeastSignificantBits()), is(existingEntry)); } | @Override public PendingHashImage getByUUID(long most, long least) throws RepositoryException { try { synchronized (uuidQuery) { mostParam.setValue(most); leastParam.setValue(least); return pendingDao.queryForFirst(uuidQuery); } } catch (SQLException e) { throw new RepositoryException("Failed to get entry by id", e); } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public PendingHashImage getByUUID(long most, long least) throws RepositoryException { try { synchronized (uuidQuery) { mostParam.setValue(most); leastParam.setValue(least); return pendingDao.queryForFirst(uuidQuery); } } catch (SQLException e) { throw new RepositoryException("Failed to get entry by id", e); } } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public PendingHashImage getByUUID(long most, long least) throws RepositoryException { try { synchronized (uuidQuery) { mostParam.setValue(most); leastParam.setValue(least); return pendingDao.queryForFirst(uuidQuery); } } catch (SQLException e) { throw new RepositoryException("Failed to get entry by id", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public PendingHashImage getByUUID(long most, long least) throws RepositoryException { try { synchronized (uuidQuery) { mostParam.setValue(most); leastParam.setValue(least); return pendingDao.queryForFirst(uuidQuery); } } catch (SQLException e) { throw new RepositoryException("Failed to get entry by id", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public PendingHashImage getByUUID(long most, long least) throws RepositoryException { try { synchronized (uuidQuery) { mostParam.setValue(most); leastParam.setValue(least); return pendingDao.queryForFirst(uuidQuery); } } catch (SQLException e) { throw new RepositoryException("Failed to get entry by id", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } |
@Test public void testRemove() throws Exception { assertThat(dao.queryForSameId(existingEntry), is(notNullValue())); cut.remove(existingEntry); assertThat(dao.queryForSameId(existingEntry), is(nullValue())); } | @Override public void remove(PendingHashImage image) throws RepositoryException { try { pendingDao.delete(image); } catch (SQLException e) { throw new RepositoryException("Failed to remove entry", e); } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public void remove(PendingHashImage image) throws RepositoryException { try { pendingDao.delete(image); } catch (SQLException e) { throw new RepositoryException("Failed to remove entry", e); } } } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public void remove(PendingHashImage image) throws RepositoryException { try { pendingDao.delete(image); } catch (SQLException e) { throw new RepositoryException("Failed to remove entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public void remove(PendingHashImage image) throws RepositoryException { try { pendingDao.delete(image); } catch (SQLException e) { throw new RepositoryException("Failed to remove entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } | OrmlitePendingHashImage implements PendingHashImageRepository { @Override public void remove(PendingHashImage image) throws RepositoryException { try { pendingDao.delete(image); } catch (SQLException e) { throw new RepositoryException("Failed to remove entry", e); } } OrmlitePendingHashImage(Dao<PendingHashImage, Integer> pendingDao); @Override synchronized boolean store(PendingHashImage image); @Override boolean exists(PendingHashImage image); @Override List<PendingHashImage> getAll(); @Override PendingHashImage getByUUID(long most, long least); @Override void remove(PendingHashImage image); } |
@Test public void testStore() throws Exception { cut.store(imageNew); assertThat(imageDao.queryForId(pathNew), is(imageNew)); } | @Override public void store(ImageRecord image) throws RepositoryException { try { imageDao.createOrUpdate(image); } catch (SQLException e) { throw new RepositoryException("Failed to store image", e); } } | OrmliteImageRepository implements ImageRepository { @Override public void store(ImageRecord image) throws RepositoryException { try { imageDao.createOrUpdate(image); } catch (SQLException e) { throw new RepositoryException("Failed to store image", e); } } } | OrmliteImageRepository implements ImageRepository { @Override public void store(ImageRecord image) throws RepositoryException { try { imageDao.createOrUpdate(image); } catch (SQLException e) { throw new RepositoryException("Failed to store image", e); } } OrmliteImageRepository(Dao<ImageRecord, String> imageDao, Dao<IgnoreRecord, String> ignoreDao); } | OrmliteImageRepository implements ImageRepository { @Override public void store(ImageRecord image) throws RepositoryException { try { imageDao.createOrUpdate(image); } catch (SQLException e) { throw new RepositoryException("Failed to store image", e); } } OrmliteImageRepository(Dao<ImageRecord, String> imageDao, Dao<IgnoreRecord, String> ignoreDao); @Override void store(ImageRecord image); @Override List<ImageRecord> getByHash(long hash); @Override ImageRecord getByPath(Path path); @Override synchronized List<ImageRecord> startsWithPath(Path directory); @Override void remove(ImageRecord image); @Override void remove(Collection<ImageRecord> images); @Override List<ImageRecord> getAll(); @Override List<ImageRecord> getAllWithoutIgnored(); @Override List<ImageRecord> getAllWithoutIgnored(Path directory); } | OrmliteImageRepository implements ImageRepository { @Override public void store(ImageRecord image) throws RepositoryException { try { imageDao.createOrUpdate(image); } catch (SQLException e) { throw new RepositoryException("Failed to store image", e); } } OrmliteImageRepository(Dao<ImageRecord, String> imageDao, Dao<IgnoreRecord, String> ignoreDao); @Override void store(ImageRecord image); @Override List<ImageRecord> getByHash(long hash); @Override ImageRecord getByPath(Path path); @Override synchronized List<ImageRecord> startsWithPath(Path directory); @Override void remove(ImageRecord image); @Override void remove(Collection<ImageRecord> images); @Override List<ImageRecord> getAll(); @Override List<ImageRecord> getAllWithoutIgnored(); @Override List<ImageRecord> getAllWithoutIgnored(Path directory); } |
@Test public void testGetByHashExists() throws Exception { assertThat(cut.getByHash(HASH_EXISTING_RECORD), containsInAnyOrder(imageExisting)); } | @Override public List<ImageRecord> getByHash(long hash) throws RepositoryException { try { return imageDao.queryForMatching(new ImageRecord(null, hash)); } catch (SQLException e) { throw new RepositoryException("Failed to query by hash", e); } } | OrmliteImageRepository implements ImageRepository { @Override public List<ImageRecord> getByHash(long hash) throws RepositoryException { try { return imageDao.queryForMatching(new ImageRecord(null, hash)); } catch (SQLException e) { throw new RepositoryException("Failed to query by hash", e); } } } | OrmliteImageRepository implements ImageRepository { @Override public List<ImageRecord> getByHash(long hash) throws RepositoryException { try { return imageDao.queryForMatching(new ImageRecord(null, hash)); } catch (SQLException e) { throw new RepositoryException("Failed to query by hash", e); } } OrmliteImageRepository(Dao<ImageRecord, String> imageDao, Dao<IgnoreRecord, String> ignoreDao); } | OrmliteImageRepository implements ImageRepository { @Override public List<ImageRecord> getByHash(long hash) throws RepositoryException { try { return imageDao.queryForMatching(new ImageRecord(null, hash)); } catch (SQLException e) { throw new RepositoryException("Failed to query by hash", e); } } OrmliteImageRepository(Dao<ImageRecord, String> imageDao, Dao<IgnoreRecord, String> ignoreDao); @Override void store(ImageRecord image); @Override List<ImageRecord> getByHash(long hash); @Override ImageRecord getByPath(Path path); @Override synchronized List<ImageRecord> startsWithPath(Path directory); @Override void remove(ImageRecord image); @Override void remove(Collection<ImageRecord> images); @Override List<ImageRecord> getAll(); @Override List<ImageRecord> getAllWithoutIgnored(); @Override List<ImageRecord> getAllWithoutIgnored(Path directory); } | OrmliteImageRepository implements ImageRepository { @Override public List<ImageRecord> getByHash(long hash) throws RepositoryException { try { return imageDao.queryForMatching(new ImageRecord(null, hash)); } catch (SQLException e) { throw new RepositoryException("Failed to query by hash", e); } } OrmliteImageRepository(Dao<ImageRecord, String> imageDao, Dao<IgnoreRecord, String> ignoreDao); @Override void store(ImageRecord image); @Override List<ImageRecord> getByHash(long hash); @Override ImageRecord getByPath(Path path); @Override synchronized List<ImageRecord> startsWithPath(Path directory); @Override void remove(ImageRecord image); @Override void remove(Collection<ImageRecord> images); @Override List<ImageRecord> getAll(); @Override List<ImageRecord> getAllWithoutIgnored(); @Override List<ImageRecord> getAllWithoutIgnored(Path directory); } |
@Test public void testSupportsExtendedAttributesNoFile() throws Exception { assertThat(ExtendedAttribute.supportsExtendedAttributes(Jimfs.newFileSystem().getPath("noEAsupport")), is(false)); } | public static boolean supportsExtendedAttributes(Path path) { try { return Files.getFileStore(path).supportsFileAttributeView(UserDefinedFileAttributeView.class); } catch (IOException e) { LOGGER.debug("Failed to check extended attributes via FileStore ({}) for {}, falling back to write test...", e.toString(), path); return checkSupportWithWrite(path); } } | ExtendedAttribute implements ExtendedAttributeQuery { public static boolean supportsExtendedAttributes(Path path) { try { return Files.getFileStore(path).supportsFileAttributeView(UserDefinedFileAttributeView.class); } catch (IOException e) { LOGGER.debug("Failed to check extended attributes via FileStore ({}) for {}, falling back to write test...", e.toString(), path); return checkSupportWithWrite(path); } } } | ExtendedAttribute implements ExtendedAttributeQuery { public static boolean supportsExtendedAttributes(Path path) { try { return Files.getFileStore(path).supportsFileAttributeView(UserDefinedFileAttributeView.class); } catch (IOException e) { LOGGER.debug("Failed to check extended attributes via FileStore ({}) for {}, falling back to write test...", e.toString(), path); return checkSupportWithWrite(path); } } } | ExtendedAttribute implements ExtendedAttributeQuery { public static boolean supportsExtendedAttributes(Path path) { try { return Files.getFileStore(path).supportsFileAttributeView(UserDefinedFileAttributeView.class); } catch (IOException e) { LOGGER.debug("Failed to check extended attributes via FileStore ({}) for {}, falling back to write test...", e.toString(), path); return checkSupportWithWrite(path); } } static String createName(String... names); static boolean supportsExtendedAttributes(Path path); static void deleteExtendedAttribute(Path path, String name); static void setExtendedAttribute(Path path, String name, String value); static void setExtendedAttribute(Path path, String name, ByteBuffer value); static ByteBuffer readExtendedAttribute(Path path, String name); static String readExtendedAttributeAsString(Path path, String name); static boolean isExtendedAttributeSet(Path path, String name); @Override boolean isEaSupported(Path path); } | ExtendedAttribute implements ExtendedAttributeQuery { public static boolean supportsExtendedAttributes(Path path) { try { return Files.getFileStore(path).supportsFileAttributeView(UserDefinedFileAttributeView.class); } catch (IOException e) { LOGGER.debug("Failed to check extended attributes via FileStore ({}) for {}, falling back to write test...", e.toString(), path); return checkSupportWithWrite(path); } } static String createName(String... names); static boolean supportsExtendedAttributes(Path path); static void deleteExtendedAttribute(Path path, String name); static void setExtendedAttribute(Path path, String name, String value); static void setExtendedAttribute(Path path, String name, ByteBuffer value); static ByteBuffer readExtendedAttribute(Path path, String name); static String readExtendedAttributeAsString(Path path, String name); static boolean isExtendedAttributeSet(Path path, String name); @Override boolean isEaSupported(Path path); static final String SIMILARIMAGE_NAMESPACE; } |
@Test public void getPeer_one() throws Exception{ SeedPeers seedPeers = new SeedPeers(NetworkParameters.prodNet()); assertThat(seedPeers.getPeer(), notNullValue()); } | public InetSocketAddress getPeer() throws PeerDiscoveryException { try { return nextPeer(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } | SeedPeers implements PeerDiscovery { public InetSocketAddress getPeer() throws PeerDiscoveryException { try { return nextPeer(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } } | SeedPeers implements PeerDiscovery { public InetSocketAddress getPeer() throws PeerDiscoveryException { try { return nextPeer(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } SeedPeers(NetworkParameters params); } | SeedPeers implements PeerDiscovery { public InetSocketAddress getPeer() throws PeerDiscoveryException { try { return nextPeer(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } SeedPeers(NetworkParameters params); InetSocketAddress getPeer(); InetSocketAddress[] getPeers(long timeoutValue, TimeUnit timeoutUnit); void shutdown(); } | SeedPeers implements PeerDiscovery { public InetSocketAddress getPeer() throws PeerDiscoveryException { try { return nextPeer(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } SeedPeers(NetworkParameters params); InetSocketAddress getPeer(); InetSocketAddress[] getPeers(long timeoutValue, TimeUnit timeoutUnit); void shutdown(); static int[] seedAddrs; } |
@Test public void testBad_Amount() throws LitecoinURIParseException { try { testObject = new LitecoinURI(NetworkParameters.prodNet(), LitecoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?amount="); fail("Expecting LitecoinURIParseException"); } catch (LitecoinURIParseException e) { assertTrue(e.getMessage().contains("amount")); } try { testObject = new LitecoinURI(NetworkParameters.prodNet(), LitecoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?amount=12X4"); fail("Expecting LitecoinURIParseException"); } catch (LitecoinURIParseException e) { assertTrue(e.getMessage().contains("amount")); } } | public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString(); static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message); static String convertToLitecoinURI(String address, BigInteger amount, String label, String message); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString(); static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message); static String convertToLitecoinURI(String address, BigInteger amount, String label, String message); static final String FIELD_MESSAGE; static final String FIELD_LABEL; static final String FIELD_AMOUNT; static final String FIELD_ADDRESS; static final String LITECOIN_SCHEME; } |
@Test public void testBad_Label() throws LitecoinURIParseException { try { testObject = new LitecoinURI(NetworkParameters.prodNet(), LitecoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?label="); fail("Expecting LitecoinURIParseException"); } catch (LitecoinURIParseException e) { assertTrue(e.getMessage().contains("label")); } } | public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString(); static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message); static String convertToLitecoinURI(String address, BigInteger amount, String label, String message); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString(); static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message); static String convertToLitecoinURI(String address, BigInteger amount, String label, String message); static final String FIELD_MESSAGE; static final String FIELD_LABEL; static final String FIELD_AMOUNT; static final String FIELD_ADDRESS; static final String LITECOIN_SCHEME; } |
@Test public void testBad_Message() throws LitecoinURIParseException { try { testObject = new LitecoinURI(NetworkParameters.prodNet(), LitecoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?message="); fail("Expecting LitecoinURIParseException"); } catch (LitecoinURIParseException e) { assertTrue(e.getMessage().contains("message")); } } | public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString(); static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message); static String convertToLitecoinURI(String address, BigInteger amount, String label, String message); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString(); static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message); static String convertToLitecoinURI(String address, BigInteger amount, String label, String message); static final String FIELD_MESSAGE; static final String FIELD_LABEL; static final String FIELD_AMOUNT; static final String FIELD_ADDRESS; static final String LITECOIN_SCHEME; } |
@Test public void testBad_Duplicated() throws LitecoinURIParseException { try { testObject = new LitecoinURI(NetworkParameters.prodNet(), LitecoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?address=aardvark"); fail("Expecting LitecoinURIParseException"); } catch (LitecoinURIParseException e) { assertTrue(e.getMessage().contains("address")); } } | public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString(); static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message); static String convertToLitecoinURI(String address, BigInteger amount, String label, String message); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString(); static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message); static String convertToLitecoinURI(String address, BigInteger amount, String label, String message); static final String FIELD_MESSAGE; static final String FIELD_LABEL; static final String FIELD_AMOUNT; static final String FIELD_ADDRESS; static final String LITECOIN_SCHEME; } |
@Test public void testBad_TooManyEquals() throws LitecoinURIParseException { try { testObject = new LitecoinURI(NetworkParameters.prodNet(), LitecoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?label=aardvark=zebra"); fail("Expecting LitecoinURIParseException"); } catch (LitecoinURIParseException e) { assertTrue(e.getMessage().contains("cannot parse name value pair")); } } | public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString(); static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message); static String convertToLitecoinURI(String address, BigInteger amount, String label, String message); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString(); static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message); static String convertToLitecoinURI(String address, BigInteger amount, String label, String message); static final String FIELD_MESSAGE; static final String FIELD_LABEL; static final String FIELD_AMOUNT; static final String FIELD_ADDRESS; static final String LITECOIN_SCHEME; } |
@Test public void testBad_TooManyQuestionMarks() throws LitecoinURIParseException { try { testObject = new LitecoinURI(NetworkParameters.prodNet(), LitecoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?label=aardvark?message=zebra"); fail("Expecting LitecoinURIParseException"); } catch (LitecoinURIParseException e) { assertTrue(e.getMessage().contains("Too many question marks")); } } | public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString(); static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message); static String convertToLitecoinURI(String address, BigInteger amount, String label, String message); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString(); static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message); static String convertToLitecoinURI(String address, BigInteger amount, String label, String message); static final String FIELD_MESSAGE; static final String FIELD_LABEL; static final String FIELD_AMOUNT; static final String FIELD_ADDRESS; static final String LITECOIN_SCHEME; } |
@Test public void oneTx() throws Exception { BigInteger v1 = Utils.toNanoCoins(1, 0); Transaction t1 = createFakeTx(params, v1, myAddress); t1.getConfidence().markBroadcastBy(new PeerAddress(InetAddress.getByName("1.2.3.4"))); t1.getConfidence().markBroadcastBy(new PeerAddress(InetAddress.getByName("5.6.7.8"))); t1.getConfidence().setSource(TransactionConfidence.Source.NETWORK); myWallet.receivePending(t1, new ArrayList<Transaction>()); Wallet wallet1 = roundTrip(myWallet); assertEquals(1, wallet1.getTransactions(true, true).size()); assertEquals(v1, wallet1.getBalance(Wallet.BalanceType.ESTIMATED)); Transaction t1copy = wallet1.getTransaction(t1.getHash()); assertArrayEquals(t1.litecoinSerialize(), t1copy.litecoinSerialize()); assertEquals(2, t1copy.getConfidence().numBroadcastPeers()); assertEquals(TransactionConfidence.Source.NETWORK, t1copy.getConfidence().getSource()); Protos.Wallet walletProto = new WalletProtobufSerializer().walletToProto(myWallet); assertEquals(Protos.Key.Type.ORIGINAL, walletProto.getKey(0).getType()); assertEquals(0, walletProto.getExtensionCount()); assertEquals(1, walletProto.getTransactionCount()); assertEquals(1, walletProto.getKeyCount()); Protos.Transaction t1p = walletProto.getTransaction(0); assertEquals(0, t1p.getBlockHashCount()); assertArrayEquals(t1.getHash().getBytes(), t1p.getHash().toByteArray()); assertEquals(Protos.Transaction.Pool.PENDING, t1p.getPool()); assertFalse(t1p.hasLockTime()); assertFalse(t1p.getTransactionInput(0).hasSequence()); assertArrayEquals(t1.getInputs().get(0).getOutpoint().getHash().getBytes(), t1p.getTransactionInput(0).getTransactionOutPointHash().toByteArray()); assertEquals(0, t1p.getTransactionInput(0).getTransactionOutPointIndex()); assertEquals(t1p.getTransactionOutput(0).getValue(), v1.longValue()); } | public Protos.Wallet walletToProto(Wallet wallet) { Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder(); walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId()); if (wallet.getDescription() != null) { walletBuilder.setDescription(wallet.getDescription()); } for (WalletTransaction wtx : wallet.getWalletTransactions()) { Protos.Transaction txProto = makeTxProto(wtx); walletBuilder.addTransaction(txProto); } for (ECKey key : wallet.getKeys()) { Protos.Key.Builder keyBuilder = Protos.Key.newBuilder().setCreationTimestamp(key.getCreationTimeSeconds() * 1000) .setType(Protos.Key.Type.ORIGINAL); if (key.getPrivKeyBytes() != null) keyBuilder.setPrivateKey(ByteString.copyFrom(key.getPrivKeyBytes())); EncryptedPrivateKey encryptedPrivateKey = key.getEncryptedPrivateKey(); if (encryptedPrivateKey != null) { Protos.EncryptedPrivateKey.Builder encryptedKeyBuilder = Protos.EncryptedPrivateKey.newBuilder() .setEncryptedPrivateKey(ByteString.copyFrom(encryptedPrivateKey.getEncryptedBytes())) .setInitialisationVector(ByteString.copyFrom(encryptedPrivateKey.getInitialisationVector())); if (key.getKeyCrypter() == null) { throw new IllegalStateException("The encrypted key " + key.toString() + " has no KeyCrypter."); } else { if (key.getKeyCrypter().getUnderstoodEncryptionType() == Protos.Wallet.EncryptionType.ENCRYPTED_SCRYPT_AES) { keyBuilder.setType(Protos.Key.Type.ENCRYPTED_SCRYPT_AES); } else { throw new IllegalArgumentException("The key " + key.toString() + " is encrypted with a KeyCrypter of type " + key.getKeyCrypter().getUnderstoodEncryptionType() + ". This WalletProtobufSerialiser does not understand that type of encryption."); } } keyBuilder.setEncryptedPrivateKey(encryptedKeyBuilder); } keyBuilder.setPublicKey(ByteString.copyFrom(key.getPubKey())); walletBuilder.addKey(keyBuilder); } Sha256Hash lastSeenBlockHash = wallet.getLastBlockSeenHash(); if (lastSeenBlockHash != null) { walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash)); walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight()); } KeyCrypter keyCrypter = wallet.getKeyCrypter(); if (keyCrypter == null) { walletBuilder.setEncryptionType(EncryptionType.UNENCRYPTED); } else { walletBuilder.setEncryptionType(keyCrypter.getUnderstoodEncryptionType()); if (keyCrypter instanceof KeyCrypterScrypt) { KeyCrypterScrypt keyCrypterScrypt = (KeyCrypterScrypt) keyCrypter; walletBuilder.setEncryptionParameters(keyCrypterScrypt.getScryptParameters()); } else { throw new RuntimeException("The wallet has encryption of type '" + keyCrypter.getUnderstoodEncryptionType() + "' but this WalletProtobufSerializer does not know how to persist this."); } } walletBuilder.setVersion(wallet.getVersion()); Collection<Protos.Extension> extensions = helper.getExtensionsToWrite(wallet); for(Protos.Extension ext : extensions) { walletBuilder.addExtension(ext); } return walletBuilder.build(); } | WalletProtobufSerializer { public Protos.Wallet walletToProto(Wallet wallet) { Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder(); walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId()); if (wallet.getDescription() != null) { walletBuilder.setDescription(wallet.getDescription()); } for (WalletTransaction wtx : wallet.getWalletTransactions()) { Protos.Transaction txProto = makeTxProto(wtx); walletBuilder.addTransaction(txProto); } for (ECKey key : wallet.getKeys()) { Protos.Key.Builder keyBuilder = Protos.Key.newBuilder().setCreationTimestamp(key.getCreationTimeSeconds() * 1000) .setType(Protos.Key.Type.ORIGINAL); if (key.getPrivKeyBytes() != null) keyBuilder.setPrivateKey(ByteString.copyFrom(key.getPrivKeyBytes())); EncryptedPrivateKey encryptedPrivateKey = key.getEncryptedPrivateKey(); if (encryptedPrivateKey != null) { Protos.EncryptedPrivateKey.Builder encryptedKeyBuilder = Protos.EncryptedPrivateKey.newBuilder() .setEncryptedPrivateKey(ByteString.copyFrom(encryptedPrivateKey.getEncryptedBytes())) .setInitialisationVector(ByteString.copyFrom(encryptedPrivateKey.getInitialisationVector())); if (key.getKeyCrypter() == null) { throw new IllegalStateException("The encrypted key " + key.toString() + " has no KeyCrypter."); } else { if (key.getKeyCrypter().getUnderstoodEncryptionType() == Protos.Wallet.EncryptionType.ENCRYPTED_SCRYPT_AES) { keyBuilder.setType(Protos.Key.Type.ENCRYPTED_SCRYPT_AES); } else { throw new IllegalArgumentException("The key " + key.toString() + " is encrypted with a KeyCrypter of type " + key.getKeyCrypter().getUnderstoodEncryptionType() + ". This WalletProtobufSerialiser does not understand that type of encryption."); } } keyBuilder.setEncryptedPrivateKey(encryptedKeyBuilder); } keyBuilder.setPublicKey(ByteString.copyFrom(key.getPubKey())); walletBuilder.addKey(keyBuilder); } Sha256Hash lastSeenBlockHash = wallet.getLastBlockSeenHash(); if (lastSeenBlockHash != null) { walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash)); walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight()); } KeyCrypter keyCrypter = wallet.getKeyCrypter(); if (keyCrypter == null) { walletBuilder.setEncryptionType(EncryptionType.UNENCRYPTED); } else { walletBuilder.setEncryptionType(keyCrypter.getUnderstoodEncryptionType()); if (keyCrypter instanceof KeyCrypterScrypt) { KeyCrypterScrypt keyCrypterScrypt = (KeyCrypterScrypt) keyCrypter; walletBuilder.setEncryptionParameters(keyCrypterScrypt.getScryptParameters()); } else { throw new RuntimeException("The wallet has encryption of type '" + keyCrypter.getUnderstoodEncryptionType() + "' but this WalletProtobufSerializer does not know how to persist this."); } } walletBuilder.setVersion(wallet.getVersion()); Collection<Protos.Extension> extensions = helper.getExtensionsToWrite(wallet); for(Protos.Extension ext : extensions) { walletBuilder.addExtension(ext); } return walletBuilder.build(); } } | WalletProtobufSerializer { public Protos.Wallet walletToProto(Wallet wallet) { Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder(); walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId()); if (wallet.getDescription() != null) { walletBuilder.setDescription(wallet.getDescription()); } for (WalletTransaction wtx : wallet.getWalletTransactions()) { Protos.Transaction txProto = makeTxProto(wtx); walletBuilder.addTransaction(txProto); } for (ECKey key : wallet.getKeys()) { Protos.Key.Builder keyBuilder = Protos.Key.newBuilder().setCreationTimestamp(key.getCreationTimeSeconds() * 1000) .setType(Protos.Key.Type.ORIGINAL); if (key.getPrivKeyBytes() != null) keyBuilder.setPrivateKey(ByteString.copyFrom(key.getPrivKeyBytes())); EncryptedPrivateKey encryptedPrivateKey = key.getEncryptedPrivateKey(); if (encryptedPrivateKey != null) { Protos.EncryptedPrivateKey.Builder encryptedKeyBuilder = Protos.EncryptedPrivateKey.newBuilder() .setEncryptedPrivateKey(ByteString.copyFrom(encryptedPrivateKey.getEncryptedBytes())) .setInitialisationVector(ByteString.copyFrom(encryptedPrivateKey.getInitialisationVector())); if (key.getKeyCrypter() == null) { throw new IllegalStateException("The encrypted key " + key.toString() + " has no KeyCrypter."); } else { if (key.getKeyCrypter().getUnderstoodEncryptionType() == Protos.Wallet.EncryptionType.ENCRYPTED_SCRYPT_AES) { keyBuilder.setType(Protos.Key.Type.ENCRYPTED_SCRYPT_AES); } else { throw new IllegalArgumentException("The key " + key.toString() + " is encrypted with a KeyCrypter of type " + key.getKeyCrypter().getUnderstoodEncryptionType() + ". This WalletProtobufSerialiser does not understand that type of encryption."); } } keyBuilder.setEncryptedPrivateKey(encryptedKeyBuilder); } keyBuilder.setPublicKey(ByteString.copyFrom(key.getPubKey())); walletBuilder.addKey(keyBuilder); } Sha256Hash lastSeenBlockHash = wallet.getLastBlockSeenHash(); if (lastSeenBlockHash != null) { walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash)); walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight()); } KeyCrypter keyCrypter = wallet.getKeyCrypter(); if (keyCrypter == null) { walletBuilder.setEncryptionType(EncryptionType.UNENCRYPTED); } else { walletBuilder.setEncryptionType(keyCrypter.getUnderstoodEncryptionType()); if (keyCrypter instanceof KeyCrypterScrypt) { KeyCrypterScrypt keyCrypterScrypt = (KeyCrypterScrypt) keyCrypter; walletBuilder.setEncryptionParameters(keyCrypterScrypt.getScryptParameters()); } else { throw new RuntimeException("The wallet has encryption of type '" + keyCrypter.getUnderstoodEncryptionType() + "' but this WalletProtobufSerializer does not know how to persist this."); } } walletBuilder.setVersion(wallet.getVersion()); Collection<Protos.Extension> extensions = helper.getExtensionsToWrite(wallet); for(Protos.Extension ext : extensions) { walletBuilder.addExtension(ext); } return walletBuilder.build(); } WalletProtobufSerializer(); } | WalletProtobufSerializer { public Protos.Wallet walletToProto(Wallet wallet) { Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder(); walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId()); if (wallet.getDescription() != null) { walletBuilder.setDescription(wallet.getDescription()); } for (WalletTransaction wtx : wallet.getWalletTransactions()) { Protos.Transaction txProto = makeTxProto(wtx); walletBuilder.addTransaction(txProto); } for (ECKey key : wallet.getKeys()) { Protos.Key.Builder keyBuilder = Protos.Key.newBuilder().setCreationTimestamp(key.getCreationTimeSeconds() * 1000) .setType(Protos.Key.Type.ORIGINAL); if (key.getPrivKeyBytes() != null) keyBuilder.setPrivateKey(ByteString.copyFrom(key.getPrivKeyBytes())); EncryptedPrivateKey encryptedPrivateKey = key.getEncryptedPrivateKey(); if (encryptedPrivateKey != null) { Protos.EncryptedPrivateKey.Builder encryptedKeyBuilder = Protos.EncryptedPrivateKey.newBuilder() .setEncryptedPrivateKey(ByteString.copyFrom(encryptedPrivateKey.getEncryptedBytes())) .setInitialisationVector(ByteString.copyFrom(encryptedPrivateKey.getInitialisationVector())); if (key.getKeyCrypter() == null) { throw new IllegalStateException("The encrypted key " + key.toString() + " has no KeyCrypter."); } else { if (key.getKeyCrypter().getUnderstoodEncryptionType() == Protos.Wallet.EncryptionType.ENCRYPTED_SCRYPT_AES) { keyBuilder.setType(Protos.Key.Type.ENCRYPTED_SCRYPT_AES); } else { throw new IllegalArgumentException("The key " + key.toString() + " is encrypted with a KeyCrypter of type " + key.getKeyCrypter().getUnderstoodEncryptionType() + ". This WalletProtobufSerialiser does not understand that type of encryption."); } } keyBuilder.setEncryptedPrivateKey(encryptedKeyBuilder); } keyBuilder.setPublicKey(ByteString.copyFrom(key.getPubKey())); walletBuilder.addKey(keyBuilder); } Sha256Hash lastSeenBlockHash = wallet.getLastBlockSeenHash(); if (lastSeenBlockHash != null) { walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash)); walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight()); } KeyCrypter keyCrypter = wallet.getKeyCrypter(); if (keyCrypter == null) { walletBuilder.setEncryptionType(EncryptionType.UNENCRYPTED); } else { walletBuilder.setEncryptionType(keyCrypter.getUnderstoodEncryptionType()); if (keyCrypter instanceof KeyCrypterScrypt) { KeyCrypterScrypt keyCrypterScrypt = (KeyCrypterScrypt) keyCrypter; walletBuilder.setEncryptionParameters(keyCrypterScrypt.getScryptParameters()); } else { throw new RuntimeException("The wallet has encryption of type '" + keyCrypter.getUnderstoodEncryptionType() + "' but this WalletProtobufSerializer does not know how to persist this."); } } walletBuilder.setVersion(wallet.getVersion()); Collection<Protos.Extension> extensions = helper.getExtensionsToWrite(wallet); for(Protos.Extension ext : extensions) { walletBuilder.addExtension(ext); } return walletBuilder.build(); } WalletProtobufSerializer(); void setWalletExtensionSerializer(WalletExtensionSerializer h); void writeWallet(Wallet wallet, OutputStream output); String walletToText(Wallet wallet); Protos.Wallet walletToProto(Wallet wallet); static ByteString hashToByteString(Sha256Hash hash); static Sha256Hash byteStringToHash(ByteString bs); Wallet readWallet(InputStream input); static Protos.Wallet parseToProto(InputStream input); } | WalletProtobufSerializer { public Protos.Wallet walletToProto(Wallet wallet) { Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder(); walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId()); if (wallet.getDescription() != null) { walletBuilder.setDescription(wallet.getDescription()); } for (WalletTransaction wtx : wallet.getWalletTransactions()) { Protos.Transaction txProto = makeTxProto(wtx); walletBuilder.addTransaction(txProto); } for (ECKey key : wallet.getKeys()) { Protos.Key.Builder keyBuilder = Protos.Key.newBuilder().setCreationTimestamp(key.getCreationTimeSeconds() * 1000) .setType(Protos.Key.Type.ORIGINAL); if (key.getPrivKeyBytes() != null) keyBuilder.setPrivateKey(ByteString.copyFrom(key.getPrivKeyBytes())); EncryptedPrivateKey encryptedPrivateKey = key.getEncryptedPrivateKey(); if (encryptedPrivateKey != null) { Protos.EncryptedPrivateKey.Builder encryptedKeyBuilder = Protos.EncryptedPrivateKey.newBuilder() .setEncryptedPrivateKey(ByteString.copyFrom(encryptedPrivateKey.getEncryptedBytes())) .setInitialisationVector(ByteString.copyFrom(encryptedPrivateKey.getInitialisationVector())); if (key.getKeyCrypter() == null) { throw new IllegalStateException("The encrypted key " + key.toString() + " has no KeyCrypter."); } else { if (key.getKeyCrypter().getUnderstoodEncryptionType() == Protos.Wallet.EncryptionType.ENCRYPTED_SCRYPT_AES) { keyBuilder.setType(Protos.Key.Type.ENCRYPTED_SCRYPT_AES); } else { throw new IllegalArgumentException("The key " + key.toString() + " is encrypted with a KeyCrypter of type " + key.getKeyCrypter().getUnderstoodEncryptionType() + ". This WalletProtobufSerialiser does not understand that type of encryption."); } } keyBuilder.setEncryptedPrivateKey(encryptedKeyBuilder); } keyBuilder.setPublicKey(ByteString.copyFrom(key.getPubKey())); walletBuilder.addKey(keyBuilder); } Sha256Hash lastSeenBlockHash = wallet.getLastBlockSeenHash(); if (lastSeenBlockHash != null) { walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash)); walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight()); } KeyCrypter keyCrypter = wallet.getKeyCrypter(); if (keyCrypter == null) { walletBuilder.setEncryptionType(EncryptionType.UNENCRYPTED); } else { walletBuilder.setEncryptionType(keyCrypter.getUnderstoodEncryptionType()); if (keyCrypter instanceof KeyCrypterScrypt) { KeyCrypterScrypt keyCrypterScrypt = (KeyCrypterScrypt) keyCrypter; walletBuilder.setEncryptionParameters(keyCrypterScrypt.getScryptParameters()); } else { throw new RuntimeException("The wallet has encryption of type '" + keyCrypter.getUnderstoodEncryptionType() + "' but this WalletProtobufSerializer does not know how to persist this."); } } walletBuilder.setVersion(wallet.getVersion()); Collection<Protos.Extension> extensions = helper.getExtensionsToWrite(wallet); for(Protos.Extension ext : extensions) { walletBuilder.addExtension(ext); } return walletBuilder.build(); } WalletProtobufSerializer(); void setWalletExtensionSerializer(WalletExtensionSerializer h); void writeWallet(Wallet wallet, OutputStream output); String walletToText(Wallet wallet); Protos.Wallet walletToProto(Wallet wallet); static ByteString hashToByteString(Sha256Hash hash); static Sha256Hash byteStringToHash(ByteString bs); Wallet readWallet(InputStream input); static Protos.Wallet parseToProto(InputStream input); } |
@Test public void testLastBlockSeenHash() throws Exception { Wallet wallet = new Wallet(params); Protos.Wallet walletProto = new WalletProtobufSerializer().walletToProto(wallet); ByteString lastSeenBlockHash = walletProto.getLastSeenBlockHash(); assertTrue(lastSeenBlockHash.isEmpty()); Block block = new Block(params, BlockTest.blockBytes); Sha256Hash blockHash = block.getHash(); wallet.setLastBlockSeenHash(blockHash); wallet.setLastBlockSeenHeight(1); Wallet wallet1 = roundTrip(wallet); assertEquals(blockHash, wallet1.getLastBlockSeenHash()); assertEquals(1, wallet1.getLastBlockSeenHeight()); Block genesisBlock = NetworkParameters.prodNet().genesisBlock; wallet.setLastBlockSeenHash(genesisBlock.getHash()); Wallet wallet2 = roundTrip(wallet); assertEquals(genesisBlock.getHash(), wallet2.getLastBlockSeenHash()); } | public Protos.Wallet walletToProto(Wallet wallet) { Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder(); walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId()); if (wallet.getDescription() != null) { walletBuilder.setDescription(wallet.getDescription()); } for (WalletTransaction wtx : wallet.getWalletTransactions()) { Protos.Transaction txProto = makeTxProto(wtx); walletBuilder.addTransaction(txProto); } for (ECKey key : wallet.getKeys()) { Protos.Key.Builder keyBuilder = Protos.Key.newBuilder().setCreationTimestamp(key.getCreationTimeSeconds() * 1000) .setType(Protos.Key.Type.ORIGINAL); if (key.getPrivKeyBytes() != null) keyBuilder.setPrivateKey(ByteString.copyFrom(key.getPrivKeyBytes())); EncryptedPrivateKey encryptedPrivateKey = key.getEncryptedPrivateKey(); if (encryptedPrivateKey != null) { Protos.EncryptedPrivateKey.Builder encryptedKeyBuilder = Protos.EncryptedPrivateKey.newBuilder() .setEncryptedPrivateKey(ByteString.copyFrom(encryptedPrivateKey.getEncryptedBytes())) .setInitialisationVector(ByteString.copyFrom(encryptedPrivateKey.getInitialisationVector())); if (key.getKeyCrypter() == null) { throw new IllegalStateException("The encrypted key " + key.toString() + " has no KeyCrypter."); } else { if (key.getKeyCrypter().getUnderstoodEncryptionType() == Protos.Wallet.EncryptionType.ENCRYPTED_SCRYPT_AES) { keyBuilder.setType(Protos.Key.Type.ENCRYPTED_SCRYPT_AES); } else { throw new IllegalArgumentException("The key " + key.toString() + " is encrypted with a KeyCrypter of type " + key.getKeyCrypter().getUnderstoodEncryptionType() + ". This WalletProtobufSerialiser does not understand that type of encryption."); } } keyBuilder.setEncryptedPrivateKey(encryptedKeyBuilder); } keyBuilder.setPublicKey(ByteString.copyFrom(key.getPubKey())); walletBuilder.addKey(keyBuilder); } Sha256Hash lastSeenBlockHash = wallet.getLastBlockSeenHash(); if (lastSeenBlockHash != null) { walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash)); walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight()); } KeyCrypter keyCrypter = wallet.getKeyCrypter(); if (keyCrypter == null) { walletBuilder.setEncryptionType(EncryptionType.UNENCRYPTED); } else { walletBuilder.setEncryptionType(keyCrypter.getUnderstoodEncryptionType()); if (keyCrypter instanceof KeyCrypterScrypt) { KeyCrypterScrypt keyCrypterScrypt = (KeyCrypterScrypt) keyCrypter; walletBuilder.setEncryptionParameters(keyCrypterScrypt.getScryptParameters()); } else { throw new RuntimeException("The wallet has encryption of type '" + keyCrypter.getUnderstoodEncryptionType() + "' but this WalletProtobufSerializer does not know how to persist this."); } } walletBuilder.setVersion(wallet.getVersion()); Collection<Protos.Extension> extensions = helper.getExtensionsToWrite(wallet); for(Protos.Extension ext : extensions) { walletBuilder.addExtension(ext); } return walletBuilder.build(); } | WalletProtobufSerializer { public Protos.Wallet walletToProto(Wallet wallet) { Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder(); walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId()); if (wallet.getDescription() != null) { walletBuilder.setDescription(wallet.getDescription()); } for (WalletTransaction wtx : wallet.getWalletTransactions()) { Protos.Transaction txProto = makeTxProto(wtx); walletBuilder.addTransaction(txProto); } for (ECKey key : wallet.getKeys()) { Protos.Key.Builder keyBuilder = Protos.Key.newBuilder().setCreationTimestamp(key.getCreationTimeSeconds() * 1000) .setType(Protos.Key.Type.ORIGINAL); if (key.getPrivKeyBytes() != null) keyBuilder.setPrivateKey(ByteString.copyFrom(key.getPrivKeyBytes())); EncryptedPrivateKey encryptedPrivateKey = key.getEncryptedPrivateKey(); if (encryptedPrivateKey != null) { Protos.EncryptedPrivateKey.Builder encryptedKeyBuilder = Protos.EncryptedPrivateKey.newBuilder() .setEncryptedPrivateKey(ByteString.copyFrom(encryptedPrivateKey.getEncryptedBytes())) .setInitialisationVector(ByteString.copyFrom(encryptedPrivateKey.getInitialisationVector())); if (key.getKeyCrypter() == null) { throw new IllegalStateException("The encrypted key " + key.toString() + " has no KeyCrypter."); } else { if (key.getKeyCrypter().getUnderstoodEncryptionType() == Protos.Wallet.EncryptionType.ENCRYPTED_SCRYPT_AES) { keyBuilder.setType(Protos.Key.Type.ENCRYPTED_SCRYPT_AES); } else { throw new IllegalArgumentException("The key " + key.toString() + " is encrypted with a KeyCrypter of type " + key.getKeyCrypter().getUnderstoodEncryptionType() + ". This WalletProtobufSerialiser does not understand that type of encryption."); } } keyBuilder.setEncryptedPrivateKey(encryptedKeyBuilder); } keyBuilder.setPublicKey(ByteString.copyFrom(key.getPubKey())); walletBuilder.addKey(keyBuilder); } Sha256Hash lastSeenBlockHash = wallet.getLastBlockSeenHash(); if (lastSeenBlockHash != null) { walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash)); walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight()); } KeyCrypter keyCrypter = wallet.getKeyCrypter(); if (keyCrypter == null) { walletBuilder.setEncryptionType(EncryptionType.UNENCRYPTED); } else { walletBuilder.setEncryptionType(keyCrypter.getUnderstoodEncryptionType()); if (keyCrypter instanceof KeyCrypterScrypt) { KeyCrypterScrypt keyCrypterScrypt = (KeyCrypterScrypt) keyCrypter; walletBuilder.setEncryptionParameters(keyCrypterScrypt.getScryptParameters()); } else { throw new RuntimeException("The wallet has encryption of type '" + keyCrypter.getUnderstoodEncryptionType() + "' but this WalletProtobufSerializer does not know how to persist this."); } } walletBuilder.setVersion(wallet.getVersion()); Collection<Protos.Extension> extensions = helper.getExtensionsToWrite(wallet); for(Protos.Extension ext : extensions) { walletBuilder.addExtension(ext); } return walletBuilder.build(); } } | WalletProtobufSerializer { public Protos.Wallet walletToProto(Wallet wallet) { Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder(); walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId()); if (wallet.getDescription() != null) { walletBuilder.setDescription(wallet.getDescription()); } for (WalletTransaction wtx : wallet.getWalletTransactions()) { Protos.Transaction txProto = makeTxProto(wtx); walletBuilder.addTransaction(txProto); } for (ECKey key : wallet.getKeys()) { Protos.Key.Builder keyBuilder = Protos.Key.newBuilder().setCreationTimestamp(key.getCreationTimeSeconds() * 1000) .setType(Protos.Key.Type.ORIGINAL); if (key.getPrivKeyBytes() != null) keyBuilder.setPrivateKey(ByteString.copyFrom(key.getPrivKeyBytes())); EncryptedPrivateKey encryptedPrivateKey = key.getEncryptedPrivateKey(); if (encryptedPrivateKey != null) { Protos.EncryptedPrivateKey.Builder encryptedKeyBuilder = Protos.EncryptedPrivateKey.newBuilder() .setEncryptedPrivateKey(ByteString.copyFrom(encryptedPrivateKey.getEncryptedBytes())) .setInitialisationVector(ByteString.copyFrom(encryptedPrivateKey.getInitialisationVector())); if (key.getKeyCrypter() == null) { throw new IllegalStateException("The encrypted key " + key.toString() + " has no KeyCrypter."); } else { if (key.getKeyCrypter().getUnderstoodEncryptionType() == Protos.Wallet.EncryptionType.ENCRYPTED_SCRYPT_AES) { keyBuilder.setType(Protos.Key.Type.ENCRYPTED_SCRYPT_AES); } else { throw new IllegalArgumentException("The key " + key.toString() + " is encrypted with a KeyCrypter of type " + key.getKeyCrypter().getUnderstoodEncryptionType() + ". This WalletProtobufSerialiser does not understand that type of encryption."); } } keyBuilder.setEncryptedPrivateKey(encryptedKeyBuilder); } keyBuilder.setPublicKey(ByteString.copyFrom(key.getPubKey())); walletBuilder.addKey(keyBuilder); } Sha256Hash lastSeenBlockHash = wallet.getLastBlockSeenHash(); if (lastSeenBlockHash != null) { walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash)); walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight()); } KeyCrypter keyCrypter = wallet.getKeyCrypter(); if (keyCrypter == null) { walletBuilder.setEncryptionType(EncryptionType.UNENCRYPTED); } else { walletBuilder.setEncryptionType(keyCrypter.getUnderstoodEncryptionType()); if (keyCrypter instanceof KeyCrypterScrypt) { KeyCrypterScrypt keyCrypterScrypt = (KeyCrypterScrypt) keyCrypter; walletBuilder.setEncryptionParameters(keyCrypterScrypt.getScryptParameters()); } else { throw new RuntimeException("The wallet has encryption of type '" + keyCrypter.getUnderstoodEncryptionType() + "' but this WalletProtobufSerializer does not know how to persist this."); } } walletBuilder.setVersion(wallet.getVersion()); Collection<Protos.Extension> extensions = helper.getExtensionsToWrite(wallet); for(Protos.Extension ext : extensions) { walletBuilder.addExtension(ext); } return walletBuilder.build(); } WalletProtobufSerializer(); } | WalletProtobufSerializer { public Protos.Wallet walletToProto(Wallet wallet) { Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder(); walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId()); if (wallet.getDescription() != null) { walletBuilder.setDescription(wallet.getDescription()); } for (WalletTransaction wtx : wallet.getWalletTransactions()) { Protos.Transaction txProto = makeTxProto(wtx); walletBuilder.addTransaction(txProto); } for (ECKey key : wallet.getKeys()) { Protos.Key.Builder keyBuilder = Protos.Key.newBuilder().setCreationTimestamp(key.getCreationTimeSeconds() * 1000) .setType(Protos.Key.Type.ORIGINAL); if (key.getPrivKeyBytes() != null) keyBuilder.setPrivateKey(ByteString.copyFrom(key.getPrivKeyBytes())); EncryptedPrivateKey encryptedPrivateKey = key.getEncryptedPrivateKey(); if (encryptedPrivateKey != null) { Protos.EncryptedPrivateKey.Builder encryptedKeyBuilder = Protos.EncryptedPrivateKey.newBuilder() .setEncryptedPrivateKey(ByteString.copyFrom(encryptedPrivateKey.getEncryptedBytes())) .setInitialisationVector(ByteString.copyFrom(encryptedPrivateKey.getInitialisationVector())); if (key.getKeyCrypter() == null) { throw new IllegalStateException("The encrypted key " + key.toString() + " has no KeyCrypter."); } else { if (key.getKeyCrypter().getUnderstoodEncryptionType() == Protos.Wallet.EncryptionType.ENCRYPTED_SCRYPT_AES) { keyBuilder.setType(Protos.Key.Type.ENCRYPTED_SCRYPT_AES); } else { throw new IllegalArgumentException("The key " + key.toString() + " is encrypted with a KeyCrypter of type " + key.getKeyCrypter().getUnderstoodEncryptionType() + ". This WalletProtobufSerialiser does not understand that type of encryption."); } } keyBuilder.setEncryptedPrivateKey(encryptedKeyBuilder); } keyBuilder.setPublicKey(ByteString.copyFrom(key.getPubKey())); walletBuilder.addKey(keyBuilder); } Sha256Hash lastSeenBlockHash = wallet.getLastBlockSeenHash(); if (lastSeenBlockHash != null) { walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash)); walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight()); } KeyCrypter keyCrypter = wallet.getKeyCrypter(); if (keyCrypter == null) { walletBuilder.setEncryptionType(EncryptionType.UNENCRYPTED); } else { walletBuilder.setEncryptionType(keyCrypter.getUnderstoodEncryptionType()); if (keyCrypter instanceof KeyCrypterScrypt) { KeyCrypterScrypt keyCrypterScrypt = (KeyCrypterScrypt) keyCrypter; walletBuilder.setEncryptionParameters(keyCrypterScrypt.getScryptParameters()); } else { throw new RuntimeException("The wallet has encryption of type '" + keyCrypter.getUnderstoodEncryptionType() + "' but this WalletProtobufSerializer does not know how to persist this."); } } walletBuilder.setVersion(wallet.getVersion()); Collection<Protos.Extension> extensions = helper.getExtensionsToWrite(wallet); for(Protos.Extension ext : extensions) { walletBuilder.addExtension(ext); } return walletBuilder.build(); } WalletProtobufSerializer(); void setWalletExtensionSerializer(WalletExtensionSerializer h); void writeWallet(Wallet wallet, OutputStream output); String walletToText(Wallet wallet); Protos.Wallet walletToProto(Wallet wallet); static ByteString hashToByteString(Sha256Hash hash); static Sha256Hash byteStringToHash(ByteString bs); Wallet readWallet(InputStream input); static Protos.Wallet parseToProto(InputStream input); } | WalletProtobufSerializer { public Protos.Wallet walletToProto(Wallet wallet) { Protos.Wallet.Builder walletBuilder = Protos.Wallet.newBuilder(); walletBuilder.setNetworkIdentifier(wallet.getNetworkParameters().getId()); if (wallet.getDescription() != null) { walletBuilder.setDescription(wallet.getDescription()); } for (WalletTransaction wtx : wallet.getWalletTransactions()) { Protos.Transaction txProto = makeTxProto(wtx); walletBuilder.addTransaction(txProto); } for (ECKey key : wallet.getKeys()) { Protos.Key.Builder keyBuilder = Protos.Key.newBuilder().setCreationTimestamp(key.getCreationTimeSeconds() * 1000) .setType(Protos.Key.Type.ORIGINAL); if (key.getPrivKeyBytes() != null) keyBuilder.setPrivateKey(ByteString.copyFrom(key.getPrivKeyBytes())); EncryptedPrivateKey encryptedPrivateKey = key.getEncryptedPrivateKey(); if (encryptedPrivateKey != null) { Protos.EncryptedPrivateKey.Builder encryptedKeyBuilder = Protos.EncryptedPrivateKey.newBuilder() .setEncryptedPrivateKey(ByteString.copyFrom(encryptedPrivateKey.getEncryptedBytes())) .setInitialisationVector(ByteString.copyFrom(encryptedPrivateKey.getInitialisationVector())); if (key.getKeyCrypter() == null) { throw new IllegalStateException("The encrypted key " + key.toString() + " has no KeyCrypter."); } else { if (key.getKeyCrypter().getUnderstoodEncryptionType() == Protos.Wallet.EncryptionType.ENCRYPTED_SCRYPT_AES) { keyBuilder.setType(Protos.Key.Type.ENCRYPTED_SCRYPT_AES); } else { throw new IllegalArgumentException("The key " + key.toString() + " is encrypted with a KeyCrypter of type " + key.getKeyCrypter().getUnderstoodEncryptionType() + ". This WalletProtobufSerialiser does not understand that type of encryption."); } } keyBuilder.setEncryptedPrivateKey(encryptedKeyBuilder); } keyBuilder.setPublicKey(ByteString.copyFrom(key.getPubKey())); walletBuilder.addKey(keyBuilder); } Sha256Hash lastSeenBlockHash = wallet.getLastBlockSeenHash(); if (lastSeenBlockHash != null) { walletBuilder.setLastSeenBlockHash(hashToByteString(lastSeenBlockHash)); walletBuilder.setLastSeenBlockHeight(wallet.getLastBlockSeenHeight()); } KeyCrypter keyCrypter = wallet.getKeyCrypter(); if (keyCrypter == null) { walletBuilder.setEncryptionType(EncryptionType.UNENCRYPTED); } else { walletBuilder.setEncryptionType(keyCrypter.getUnderstoodEncryptionType()); if (keyCrypter instanceof KeyCrypterScrypt) { KeyCrypterScrypt keyCrypterScrypt = (KeyCrypterScrypt) keyCrypter; walletBuilder.setEncryptionParameters(keyCrypterScrypt.getScryptParameters()); } else { throw new RuntimeException("The wallet has encryption of type '" + keyCrypter.getUnderstoodEncryptionType() + "' but this WalletProtobufSerializer does not know how to persist this."); } } walletBuilder.setVersion(wallet.getVersion()); Collection<Protos.Extension> extensions = helper.getExtensionsToWrite(wallet); for(Protos.Extension ext : extensions) { walletBuilder.addExtension(ext); } return walletBuilder.build(); } WalletProtobufSerializer(); void setWalletExtensionSerializer(WalletExtensionSerializer h); void writeWallet(Wallet wallet, OutputStream output); String walletToText(Wallet wallet); Protos.Wallet walletToProto(Wallet wallet); static ByteString hashToByteString(Sha256Hash hash); static Sha256Hash byteStringToHash(ByteString bs); Wallet readWallet(InputStream input); static Protos.Wallet parseToProto(InputStream input); } |
@Test public void balances() throws Exception { BigInteger nanos = Utils.toNanoCoins(1, 0); Transaction tx1 = sendMoneyToWallet(nanos, AbstractBlockChain.NewBlockType.BEST_CHAIN); assertEquals(nanos, tx1.getValueSentToMe(wallet, true)); Transaction send1 = wallet.createSend(new ECKey().toAddress(params), toNanoCoins(0, 10)); Transaction send2 = new Transaction(params, send1.litecoinSerialize()); assertEquals(nanos, send2.getValueSentFromMe(wallet)); assertEquals(BigInteger.ZERO.subtract(toNanoCoins(0, 10)), send2.getValue(wallet)); } | public Transaction createSend(Address address, BigInteger nanocoins) { SendRequest req = SendRequest.to(address, nanocoins); if (completeTx(req)) { return req.tx; } else { return null; } } | Wallet implements Serializable, BlockChainListener { public Transaction createSend(Address address, BigInteger nanocoins) { SendRequest req = SendRequest.to(address, nanocoins); if (completeTx(req)) { return req.tx; } else { return null; } } } | Wallet implements Serializable, BlockChainListener { public Transaction createSend(Address address, BigInteger nanocoins) { SendRequest req = SendRequest.to(address, nanocoins); if (completeTx(req)) { return req.tx; } else { return null; } } Wallet(NetworkParameters params); Wallet(NetworkParameters params, KeyCrypter keyCrypter); } | Wallet implements Serializable, BlockChainListener { public Transaction createSend(Address address, BigInteger nanocoins) { SendRequest req = SendRequest.to(address, nanocoins); if (completeTx(req)) { return req.tx; } else { return null; } } Wallet(NetworkParameters params); Wallet(NetworkParameters params, KeyCrypter keyCrypter); NetworkParameters getNetworkParameters(); Iterable<ECKey> getKeys(); int getKeychainSize(); void saveToFile(File f); void setAcceptTimeLockedTransactions(boolean acceptTimeLockedTransactions); boolean doesAcceptTimeLockedTransactions(); void autosaveToFile(File f, long delayTime, TimeUnit timeUnit,
AutosaveEventListener eventListener); void saveToFileStream(OutputStream f); NetworkParameters getParams(); static Wallet loadFromFile(File f); boolean isConsistent(); static Wallet loadFromFileStream(InputStream stream); void notifyTransactionIsInBlock(Sha256Hash txHash, StoredBlock block,
BlockChain.NewBlockType blockType); void receivePending(Transaction tx, List<Transaction> dependencies); boolean isTransactionRelevant(Transaction tx); void receiveFromBlock(Transaction tx, StoredBlock block,
BlockChain.NewBlockType blockType); void notifyNewBestBlock(StoredBlock block); void addEventListener(WalletEventListener listener); boolean removeEventListener(WalletEventListener listener); void commitTx(Transaction tx); Set<Transaction> getTransactions(boolean includeDead, boolean includeInactive); Iterable<WalletTransaction> getWalletTransactions(); void addWalletTransaction(WalletTransaction wtx); List<Transaction> getTransactionsByTime(); List<Transaction> getRecentTransactions(int numTransactions, boolean includeDead); Transaction getTransaction(Sha256Hash hash); void clearTransactions(int fromHeight); Transaction createSend(Address address, BigInteger nanocoins); Transaction createSend(SendRequest req); Transaction sendCoinsOffline(SendRequest request); SendResult sendCoins(PeerGroup peerGroup, Address to, BigInteger value); SendResult sendCoins(PeerGroup peerGroup, SendRequest request); Transaction sendCoins(Peer peer, SendRequest request); boolean completeTx(SendRequest req); boolean addKey(final ECKey key); int addKeys(final List<ECKey> keys); ECKey findKeyFromPubHash(byte[] pubkeyHash); boolean hasKey(ECKey key); boolean isPubKeyHashMine(byte[] pubkeyHash); ECKey findKeyFromPubKey(byte[] pubkey); boolean isPubKeyMine(byte[] pubkey); BigInteger getBalance(); BigInteger getBalance(BalanceType balanceType); BigInteger getBalance(CoinSelector selector); @Override String toString(); String toString(boolean includePrivateKeys, AbstractBlockChain chain); void reorganize(StoredBlock splitPoint, List<StoredBlock> oldBlocks, List<StoredBlock> newBlocks); Collection<Transaction> getPendingTransactions(); long getEarliestKeyCreationTime(); Sha256Hash getLastBlockSeenHash(); void setLastBlockSeenHash(Sha256Hash lastBlockSeenHash); void setLastBlockSeenHeight(int lastBlockSeenHeight); int getLastBlockSeenHeight(); KeyParameter encrypt(CharSequence password); void encrypt(KeyCrypter keyCrypter, KeyParameter aesKey); void decrypt(KeyParameter aesKey); ECKey addNewEncryptedKey(KeyCrypter keyCrypter, KeyParameter aesKey); ECKey addNewEncryptedKey(CharSequence password); boolean checkPassword(CharSequence password); boolean checkAESKey(KeyParameter aesKey); KeyCrypter getKeyCrypter(); EncryptionType getEncryptionType(); boolean isEncrypted(); int getVersion(); void setVersion(int version); void setDescription(String description); String getDescription(); int getBloomFilterElementCount(); BloomFilter getBloomFilter(double falsePositiveRate); BloomFilter getBloomFilter(int size, double falsePositiveRate, long nTweak); CoinSelector getCoinSelector(); void setCoinSelector(CoinSelector coinSelector); void trim(final int minTransactionsToKeep); } | Wallet implements Serializable, BlockChainListener { public Transaction createSend(Address address, BigInteger nanocoins) { SendRequest req = SendRequest.to(address, nanocoins); if (completeTx(req)) { return req.tx; } else { return null; } } Wallet(NetworkParameters params); Wallet(NetworkParameters params, KeyCrypter keyCrypter); NetworkParameters getNetworkParameters(); Iterable<ECKey> getKeys(); int getKeychainSize(); void saveToFile(File f); void setAcceptTimeLockedTransactions(boolean acceptTimeLockedTransactions); boolean doesAcceptTimeLockedTransactions(); void autosaveToFile(File f, long delayTime, TimeUnit timeUnit,
AutosaveEventListener eventListener); void saveToFileStream(OutputStream f); NetworkParameters getParams(); static Wallet loadFromFile(File f); boolean isConsistent(); static Wallet loadFromFileStream(InputStream stream); void notifyTransactionIsInBlock(Sha256Hash txHash, StoredBlock block,
BlockChain.NewBlockType blockType); void receivePending(Transaction tx, List<Transaction> dependencies); boolean isTransactionRelevant(Transaction tx); void receiveFromBlock(Transaction tx, StoredBlock block,
BlockChain.NewBlockType blockType); void notifyNewBestBlock(StoredBlock block); void addEventListener(WalletEventListener listener); boolean removeEventListener(WalletEventListener listener); void commitTx(Transaction tx); Set<Transaction> getTransactions(boolean includeDead, boolean includeInactive); Iterable<WalletTransaction> getWalletTransactions(); void addWalletTransaction(WalletTransaction wtx); List<Transaction> getTransactionsByTime(); List<Transaction> getRecentTransactions(int numTransactions, boolean includeDead); Transaction getTransaction(Sha256Hash hash); void clearTransactions(int fromHeight); Transaction createSend(Address address, BigInteger nanocoins); Transaction createSend(SendRequest req); Transaction sendCoinsOffline(SendRequest request); SendResult sendCoins(PeerGroup peerGroup, Address to, BigInteger value); SendResult sendCoins(PeerGroup peerGroup, SendRequest request); Transaction sendCoins(Peer peer, SendRequest request); boolean completeTx(SendRequest req); boolean addKey(final ECKey key); int addKeys(final List<ECKey> keys); ECKey findKeyFromPubHash(byte[] pubkeyHash); boolean hasKey(ECKey key); boolean isPubKeyHashMine(byte[] pubkeyHash); ECKey findKeyFromPubKey(byte[] pubkey); boolean isPubKeyMine(byte[] pubkey); BigInteger getBalance(); BigInteger getBalance(BalanceType balanceType); BigInteger getBalance(CoinSelector selector); @Override String toString(); String toString(boolean includePrivateKeys, AbstractBlockChain chain); void reorganize(StoredBlock splitPoint, List<StoredBlock> oldBlocks, List<StoredBlock> newBlocks); Collection<Transaction> getPendingTransactions(); long getEarliestKeyCreationTime(); Sha256Hash getLastBlockSeenHash(); void setLastBlockSeenHash(Sha256Hash lastBlockSeenHash); void setLastBlockSeenHeight(int lastBlockSeenHeight); int getLastBlockSeenHeight(); KeyParameter encrypt(CharSequence password); void encrypt(KeyCrypter keyCrypter, KeyParameter aesKey); void decrypt(KeyParameter aesKey); ECKey addNewEncryptedKey(KeyCrypter keyCrypter, KeyParameter aesKey); ECKey addNewEncryptedKey(CharSequence password); boolean checkPassword(CharSequence password); boolean checkAESKey(KeyParameter aesKey); KeyCrypter getKeyCrypter(); EncryptionType getEncryptionType(); boolean isEncrypted(); int getVersion(); void setVersion(int version); void setDescription(String description); String getDescription(); int getBloomFilterElementCount(); BloomFilter getBloomFilter(double falsePositiveRate); BloomFilter getBloomFilter(int size, double falsePositiveRate, long nTweak); CoinSelector getCoinSelector(); void setCoinSelector(CoinSelector coinSelector); void trim(final int minTransactionsToKeep); public ArrayList<ECKey> keychain; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.