### Question:
RootContext { public boolean isRooted() { return root.getState() == Root.State.ROOTED; } RootContext(Root root, SuBinary suBinary, SuApp suApp, SELinux seLinux, ContextSwitch contextSwitch); boolean isRooted(); Root getRoot(); SuBinary getSuBinary(); SuApp getSuApp(); SELinux getSELinux(); ContextSwitch getContextSwitch(); @Override String toString(); static final RootContext EMPTY; }### Answer:
@Test public void testRoot() { final Root root = mock(Root.class); final SuBinary binary = mock(SuBinary.class); final SuApp app = mock(SuApp.class); final SELinux seLinux = mock(SELinux.class); final RootContext.ContextSwitch contextSwitch = mock(RootContext.ContextSwitch.class); final RootContext rootContext = new RootContext(root, binary, app, seLinux, contextSwitch); when(root.getState()).thenReturn(Root.State.ROOTED); assertThat(rootContext.isRooted(), is(true)); when(root.getState()).thenReturn(Root.State.DENIED); assertThat(rootContext.isRooted(), is(false)); }