public void testPutTemporaryBlip() throws Exception { Conversation conversation = mock(Conversation.class); ConversationBlip blip = mock(ConversationBlip.class); String tempBlipId = OperationContextImpl.TEMP_ID_MARKER + "random"; String blipId = "b+1234"; when(blip.getId()).thenReturn(blipId); when(conversation.getBlip(blipId)).thenReturn(blip); operationContext.putBlip(tempBlipId, blip); assertEquals("Expected blip for the given tempId", operationContext.getBlip(conversation, tempBlipId), blip); assertEquals("Expected blip when its non temporary id is given", operationContext.getBlip(conversation, blipId), blip); } }
public void testPutTemporaryBlip() throws Exception { Conversation conversation = mock(Conversation.class); ConversationBlip blip = mock(ConversationBlip.class); String tempBlipId = OperationContextImpl.TEMP_ID_MARKER + "random"; String blipId = "b+1234"; when(blip.getId()).thenReturn(blipId); when(conversation.getBlip(blipId)).thenReturn(blip); operationContext.putBlip(tempBlipId, blip); assertEquals("Expected blip for the given tempId", operationContext.getBlip(conversation, tempBlipId), blip); assertEquals("Expected blip when its non temporary id is given", operationContext.getBlip(conversation, blipId), blip); } }
public void testPutNonTemporaryBlip() throws Exception { // Non temporary blip is ignored Conversation conversation = mock(Conversation.class); ConversationBlip blip = mock(ConversationBlip.class); String blipId = "b+1234"; when(blip.getId()).thenReturn(blipId); when(conversation.getBlip(blipId)).thenReturn(blip); operationContext.putBlip(blip.getId(), blip); assertEquals(operationContext.getBlip(conversation, blipId), blip); }
public void testPutNonTemporaryBlip() throws Exception { // Non temporary blip is ignored Conversation conversation = mock(Conversation.class); ConversationBlip blip = mock(ConversationBlip.class); String blipId = "b+1234"; when(blip.getId()).thenReturn(blipId); when(conversation.getBlip(blipId)).thenReturn(blip); operationContext.putBlip(blip.getId(), blip); assertEquals(operationContext.getBlip(conversation, blipId), blip); }
/** * Methods that checks that the new blip was actually created and stored in * the context. As well as that it checks its contents */ private ConversationBlip checkAndGetNewBlip( OperationContextImpl context, ObservableConversation conversation, JsonRpcResponse response) throws InvalidRequestException { // Retrieve the blip using the context so that the temp blip storage is // checked ConversationBlip newBlip = context.getBlip(conversation, TEMP_BLIP_ID); assertEquals("The response didn't contain the id of the new blip", newBlip.getId(), response.getData().get(ParamsProperty.NEW_BLIP_ID)); String actualContent = newBlip.getContent().toXmlString(); assertTrue("Expected the new blip to contain the contens as specified in the operation", actualContent.contains(NEW_BLIP_CONTENT)); return newBlip; } }
/** * Methods that checks that the new blip was actually created and stored in * the context. As well as that it checks its contents */ private ConversationBlip checkAndGetNewBlip( OperationContextImpl context, ObservableConversation conversation, JsonRpcResponse response) throws InvalidRequestException { // Retrieve the blip using the context so that the temp blip storage is // checked ConversationBlip newBlip = context.getBlip(conversation, TEMP_BLIP_ID); assertEquals("The response didn't contain the id of the new blip", newBlip.getId(), response.getData().get(ParamsProperty.NEW_BLIP_ID)); String actualContent = newBlip.getContent().toXmlString(); assertTrue("Expected the new blip to contain the contens as specified in the operation", actualContent.contains(NEW_BLIP_CONTENT)); return newBlip; } }