Skip to content

Instantly share code, notes, and snippets.

@chaudum
Last active August 29, 2015 14:06
Show Gist options
  • Save chaudum/240bb5f38a3409d7a656 to your computer and use it in GitHub Desktop.
Save chaudum/240bb5f38a3409d7a656 to your computer and use it in GitHub Desktop.
Mocking
OsService osService = mock(OsService.class);
OsStats osStats = mock(OsStats.class);
OsStats.Mem mem = mock(OsStats.Mem.class);
when(osStats.mem()).thenReturn(mem);
when(mem.actualFree()).thenReturn(byteSizeValue);
when(mem.actualUsed()).thenReturn(byteSizeValue);
when(mem.usedPercent()).thenReturn((short) 22);
when(mem.freePercent()).thenReturn((short) 78);
bind(OsService.class).toInstance(osService);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment