@Test public void testInsert() throws Exception { // setup koalaGCPastImpl = new KoalaGCPastImpl( node, storageManager, null, 0, instance, new KoalaPastPolicy(), 0, storageManager, KoalaNode.DEFAULT_NUMBER_OF_DHT_BACKUPS, koalaIdFactory, koalaPiEntityFactory) { @Override protected void sendRequest( rice.p2p.commonapi.Id id, PastMessage message, Continuation command) { contentId = id; receivedInserRequestContinuation = command; receivedInserRequestPastmessage = message; } }; // act koalaGCPastImpl.insert(content, 0, continuation); // assert assertEquals(contentId, content.getId()); assertTrue(receivedInserRequestPastmessage instanceof InsertRequestMessage); assertEquals(receivedInserRequestContinuation, continuation); }
@Test public void testInsertGetsVersion() { // setup KoalaGCPastImpl localGcPastImpl = new KoalaGCPastImpl( node, storageManager, null, 0, instance, new KoalaPastPolicy(), 0, storageManager, KoalaNode.DEFAULT_NUMBER_OF_DHT_BACKUPS, koalaIdFactory, koalaPiEntityFactory) { @Override protected void sendRequest( rice.p2p.commonapi.Id id, PastMessage message, Continuation command) { sentId = id; sentMessage = message; callBackContinuation = command; } }; PastContent content = new KoalaPiEntityContent( Id.build("bob"), "the builder", false, "text", 0, NodeScope.AVAILABILITY_ZONE, "tv:series", 18); Continuation command = mock(Continuation.class); // act localGcPastImpl.insert(content, command); // assert assertEquals(sentId, Id.build("bob")); assertTrue(sentMessage instanceof InsertRequestMessage); assertEquals(18, ((InsertRequestMessage) sentMessage).getExpiration()); assertEquals(content, ((InsertRequestMessage) sentMessage).getContent()); assertEquals(command, callBackContinuation); }