public void testAddedParticipantIsRetreived() { ParticipantId creator = target.getParticipantIds().iterator().next(); ParticipantId fake = new ParticipantId("bill@foo.com"); target.addParticipant(fake); assertEquals(Arrays.asList(creator, fake), CollectionUtils.newArrayList(target.getParticipantIds())); }
public void testAddedParticipantIsRetreived() { ParticipantId creator = target.getParticipantIds().iterator().next(); ParticipantId fake = new ParticipantId("bill@foo.com"); target.addParticipant(fake); assertEquals(Arrays.asList(creator, fake), CollectionUtils.newArrayList(target.getParticipantIds())); }
public void testRemovedParticipantNoLongerRetrieved() { ParticipantId creator = target.getParticipantIds().iterator().next(); ParticipantId fake = new ParticipantId("bill@foo.com"); target.addParticipant(fake); target.removeParticipant(fake); assertEquals(Collections.singletonList(creator), CollectionUtils.newArrayList(target.getParticipantIds())); }
public void testRemovedParticipantNoLongerRetrieved() { ParticipantId creator = target.getParticipantIds().iterator().next(); ParticipantId fake = new ParticipantId("bill@foo.com"); target.addParticipant(fake); target.removeParticipant(fake); assertEquals(Collections.singletonList(creator), CollectionUtils.newArrayList(target.getParticipantIds())); }
public void testParticipantsAreASet() { ParticipantId creator = target.getParticipantIds().iterator().next(); ParticipantId fake1 = new ParticipantId("joe"); ParticipantId fake2 = new ParticipantId("bill"); List<ParticipantId> participants = CollectionUtils.newArrayList(creator, fake1, fake2); target.addParticipant(fake1); target.addParticipant(fake2); assertEquals(participants, CollectionUtils.newArrayList(target.getParticipantIds())); target.addParticipant(fake2); assertEquals(participants, CollectionUtils.newArrayList(target.getParticipantIds())); }
public void testParticipantsAreASet() { ParticipantId creator = target.getParticipantIds().iterator().next(); ParticipantId fake1 = new ParticipantId("joe"); ParticipantId fake2 = new ParticipantId("bill"); List<ParticipantId> participants = CollectionUtils.newArrayList(creator, fake1, fake2); target.addParticipant(fake1); target.addParticipant(fake2); assertEquals(participants, CollectionUtils.newArrayList(target.getParticipantIds())); target.addParticipant(fake2); assertEquals(participants, CollectionUtils.newArrayList(target.getParticipantIds())); }
case WAVELET_ADD_PARTICIPANT_NEWSYNTAX: if (conversation.getParticipantIds().contains(targetParticipant)) { String message = targetParticipant.getAddress() + " is already a " + "member of wavelet"; LOG.info(message); case WAVELET_REMOVE_PARTICIPANT_NEWSYNTAX: if (!conversation.getParticipantIds().contains(targetParticipant)) {
public void testAddParticipant() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot(); String rootBlipId = ConversationUtil.getRootBlipId(conversation); // Confirm alex is not on wave prior to operation. Set<ParticipantId> participants = conversation.getParticipantIds(); assertFalse("Alex should not be a participant on wavelet prior to operation to add him.", participants.contains(ALEX)); OperationRequest operation = operationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX, rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID,ALEX.getAddress())); service.execute(operation, context, ROBOT); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse("Add Participant generated error in service execution.", response.isError()); // Verify Alex is now a participant on the wave. participants = conversation.getParticipantIds(); assertTrue("Alex should now be a participant on the wavelet.", participants.contains(ALEX)); }
public void testAddParticipant() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot(); String rootBlipId = ConversationUtil.getRootBlipId(conversation); // Confirm alex is not on wave prior to operation. Set<ParticipantId> participants = conversation.getParticipantIds(); assertFalse("Alex should not be a participant on wavelet prior to operation to add him.", participants.contains(ALEX)); OperationRequest operation = operationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX, rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID,ALEX.getAddress())); service.execute(operation, context, ROBOT); JsonRpcResponse response = context.getResponse(OPERATION_ID); assertFalse("Add Participant generated error in service execution.", response.isError()); // Verify Alex is now a participant on the wave. participants = conversation.getParticipantIds(); assertTrue("Alex should now be a participant on the wavelet.", participants.contains(ALEX)); }
public void testRemoveParticipant() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot(); String rootBlipId = ConversationUtil.getRootBlipId(conversation); // Confirm alex is not on wave prior to operation. Set<ParticipantId> participants = conversation.getParticipantIds(); assertFalse("Alex should not be a participant on wavelet prior to operation to add him.", participants.contains(ALEX)); OperationRequest operation = new OperationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX.method(), OPERATION_ID, s(WAVE_ID), s(WAVELET_ID), rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID, ALEX.getAddress())); service.execute(operation, context, ROBOT); // Verify Alex is now a participant on the wave. participants = conversation.getParticipantIds(); assertTrue("Alex should now be a participant on the wavelet.", participants.contains(ALEX)); // Attempt to remove Alex. OperationRequest operation2 = operationRequest(OperationType.WAVELET_REMOVE_PARTICIPANT_NEWSYNTAX, OPERATION2_ID, rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID, ALEX.getAddress())); service.execute(operation2, context, ROBOT); // Verify Alex is no longer a participant on the wave. participants = conversation.getParticipantIds(); assertFalse("Alex should no longer be a participant on the wavelet.", participants.contains(ALEX)); }
public void testRemoveParticipant() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot(); String rootBlipId = ConversationUtil.getRootBlipId(conversation); // Confirm alex is not on wave prior to operation. Set<ParticipantId> participants = conversation.getParticipantIds(); assertFalse("Alex should not be a participant on wavelet prior to operation to add him.", participants.contains(ALEX)); OperationRequest operation = new OperationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX.method(), OPERATION_ID, s(WAVE_ID), s(WAVELET_ID), rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID, ALEX.getAddress())); service.execute(operation, context, ROBOT); // Verify Alex is now a participant on the wave. participants = conversation.getParticipantIds(); assertTrue("Alex should now be a participant on the wavelet.", participants.contains(ALEX)); // Attempt to remove Alex. OperationRequest operation2 = operationRequest(OperationType.WAVELET_REMOVE_PARTICIPANT_NEWSYNTAX, OPERATION2_ID, rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID, ALEX.getAddress())); service.execute(operation2, context, ROBOT); // Verify Alex is no longer a participant on the wave. participants = conversation.getParticipantIds(); assertFalse("Alex should no longer be a participant on the wavelet.", participants.contains(ALEX)); }
public void testAddThrowsOnDuplicateParticipant() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot(); String rootBlipId = ConversationUtil.getRootBlipId(conversation); // Confirm robot is on wave prior to operation to re-add it. Set<ParticipantId> participants = conversation.getParticipantIds(); assertTrue("Robot should be a participant on wavelet prior to test operation to add it.", participants.contains(ROBOT)); OperationRequest operation = operationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX, rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID, ROBOT.getAddress())); try { service.execute(operation, context, ROBOT); fail("Duplicate add of participant should have generated error in service execution."); } catch(InvalidRequestException e) { // Good. } }
public void testRemoveThrowsOnNonWaveletParticipant() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot(); String rootBlipId = ConversationUtil.getRootBlipId(conversation); // Confirm alex is not on wave prior to operation. Set<ParticipantId> participants = conversation.getParticipantIds(); assertFalse("Alex should not be a participant on wavelet prior to operation to add him.", participants.contains(ALEX)); OperationRequest operation = operationRequest(OperationType.WAVELET_REMOVE_PARTICIPANT_NEWSYNTAX, rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID, ALEX.getAddress())); try { service.execute(operation, context, ROBOT); fail("Removal of non-participant should have generated error in service execution."); } catch(InvalidRequestException e) { // Good. } }
public void testAddThrowsOnDuplicateParticipant() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot(); String rootBlipId = ConversationUtil.getRootBlipId(conversation); // Confirm robot is on wave prior to operation to re-add it. Set<ParticipantId> participants = conversation.getParticipantIds(); assertTrue("Robot should be a participant on wavelet prior to test operation to add it.", participants.contains(ROBOT)); OperationRequest operation = operationRequest(OperationType.WAVELET_ADD_PARTICIPANT_NEWSYNTAX, rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID, ROBOT.getAddress())); try { service.execute(operation, context, ROBOT); fail("Duplicate add of participant should have generated error in service execution."); } catch(InvalidRequestException e) { // Good. } }
public void testRemoveThrowsOnNonWaveletParticipant() throws Exception { OperationContextImpl context = helper.getContext(); ObservableConversation conversation = context.openConversation(WAVE_ID, WAVELET_ID, ROBOT).getRoot(); String rootBlipId = ConversationUtil.getRootBlipId(conversation); // Confirm alex is not on wave prior to operation. Set<ParticipantId> participants = conversation.getParticipantIds(); assertFalse("Alex should not be a participant on wavelet prior to operation to add him.", participants.contains(ALEX)); OperationRequest operation = operationRequest(OperationType.WAVELET_REMOVE_PARTICIPANT_NEWSYNTAX, rootBlipId, Parameter.of(ParamsProperty.PARTICIPANT_ID, ALEX.getAddress())); try { service.execute(operation, context, ROBOT); fail("Removal of non-participant should have generated error in service execution."); } catch(InvalidRequestException e) { // Good. } }