### Question:
FontInstaller { static Observable<String> generateCommands(FontPackage fontPackage, Context context) { return Observable.from(fontPackage.getFontSet()) .map(FontInstaller::getFileOrThrow) .map(FontInstaller::createInstallCommand) .toList() .startWith(Arrays.asList(MOUNT_SYSTEM_COMMAND, createLockscreenFixCommand(context))) .flatMapIterable(commands -> commands); }  static Observable<List<String>> install(FontPackage fontPackage, Context context);  }### Answer:
@Test public void testGenerateCommands_systemMountedFirst() throws Exception { downloadFontPack(); TestSubscriber<String> testSubscriber = new TestSubscriber<>(); FontInstaller.generateCommands(MOCK_FONT_PACK, null).subscribe(testSubscriber); List<String> commands = testSubscriber.getOnNextEvents(); assertEquals(SystemConstants.MOUNT_SYSTEM_COMMAND, commands.get(0)); deleteDownloadFolder(); }
@Test public void testGenerateCommands_containsInstallCommands() throws Exception { downloadFontPack(); TestSubscriber<String> testSubscriber = new TestSubscriber<>(); FontInstaller.generateCommands(MOCK_FONT_PACK, null).subscribe(testSubscriber); List<String> commands = testSubscriber.getOnNextEvents(); assertTrue(commands.containsAll(EXPECTED_COMMANDS)); deleteDownloadFolder(); }
@Test public void testGenerateCommands_installExceptionIfFilesNonexistent() throws Exception { TestSubscriber<String> testSubscriber = new TestSubscriber<>(); FontInstaller.generateCommands(MOCK_FONT_PACK, null).subscribe(testSubscriber); testSubscriber.assertError(FontInstaller.InstallException.class); }