@Test public void assertListFromServerIsRetrievedOnce() throws Exception { when(server.execute(isA(MaskedArgumentListBuilder.class))) .thenReturn( new StringReader( "--------- -------------- -------- ----------------------------------------------------------------------------------------------------------\n" + "\n" + "name1 SND\\redsolo_cp COMPUTER\n")); Workspaces workspaces = new Workspaces(server); Workspace workspace = workspaces.getWorkspace("name1"); assertNotNull("Workspace was null", workspace); workspace = workspaces.getWorkspace("name1"); assertNotNull("Workspace was null", workspace); verify(server, times(1)).execute(isA(MaskedArgumentListBuilder.class)); }
@Test public void assertGettingNewWorkspaceIsNotRetrievingServerList() throws Exception { when(server.execute(isA(MaskedArgumentListBuilder.class))).thenReturn(new StringReader("")); Workspaces workspaces = new Workspaces(server); workspaces.newWorkspace("name1"); assertNotNull("The get new workspace returned null", workspaces.getWorkspace("name1")); verify(server, times(1)).execute(isA(MaskedArgumentListBuilder.class)); }
@Test public void assertGetUnknownWorkspaceReturnsNull() throws Exception { when(server.execute(isA(MaskedArgumentListBuilder.class))).thenReturn(new StringReader("")); Workspaces workspaces = new Workspaces(server); assertNull("The unknown workspace was not null", workspaces.getWorkspace("name1")); }