Skip to content

Commit

Permalink
Remove duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
gpedder-anaplan committed Aug 15, 2017
1 parent 57d029b commit 800e721
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions test/fitnesse/testsystems/slim/InProcessSlimClientBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,7 @@ public void createSlimClientWithFixtureInteraction() {
Descriptor descriptor = mock(Descriptor.class);
when(descriptor.getVariable("slim.flags")).thenReturn("-i " + InteractionDemo.class.getName());

InProcessSlimClientBuilder slimClientBuilder = spy(new InProcessSlimClientBuilder(descriptor));

// Capture the interaction to see if it's the right one
ArgumentCaptor<FixtureInteraction> interactionCaptor = ArgumentCaptor.forClass(FixtureInteraction.class);

slimClientBuilder.build();
verify(slimClientBuilder).createSlimServer(interactionCaptor.capture(), anyInt(), anyBoolean());
FixtureInteraction interaction = interactionCaptor.getValue();
FixtureInteraction interaction = captureInteraction(descriptor);

assertNotNull(interaction);
assertNotEquals(DefaultInteraction.class, interaction.getClass());
Expand All @@ -60,16 +53,19 @@ public void createSlimClientWithoutFixtureInteraction() throws Exception {
Descriptor descriptor = spy(Descriptor.class);
when(descriptor.getVariable("slim.flags")).thenReturn(null);

FixtureInteraction interaction = captureInteraction(descriptor);

assertNotNull(interaction);
assertEquals(DefaultInteraction.class, interaction.getClass());
}

private FixtureInteraction captureInteraction(Descriptor descriptor) {
InProcessSlimClientBuilder slimClientBuilder = spy(new InProcessSlimClientBuilder(descriptor));

// Capture the interaction to see if it's the right one
ArgumentCaptor<FixtureInteraction> interactionCaptor = ArgumentCaptor.forClass(FixtureInteraction.class);

slimClientBuilder.build();
verify(slimClientBuilder).createSlimServer(interactionCaptor.capture(), anyInt(), anyBoolean());
FixtureInteraction interaction = interactionCaptor.getValue();

assertNotNull(interaction);
assertEquals(DefaultInteraction.class, interaction.getClass());
return interactionCaptor.getValue();
}
}

0 comments on commit 800e721

Please sign in to comment.