ListAllSignatureFilesCommand implements DroidCommand { @Override public void execute() { Map<SignatureType, SortedMap<String, SignatureFileInfo>> sigFiles = signatureManager.getAvailableSignatureFiles(); if (sigFiles.isEmpty()) { printWriter.println(I18N.getResource(I18N.NO_SIG_FILES_AVAILABLE)); } else { for (SortedMap<String, SignatureFileInfo> sigFilesForType : sigFiles.values()) { for (SignatureFileInfo info : sigFilesForType.values()) { printWriter.println(I18N.getResource(I18N.DEFAULT_SIGNATURE_VERSION, info.getType(), info.getVersion(), info.getFile().getFileName().toString())); } } } }  @Override void execute(); void setPrintWriter(PrintWriter printWriter); void setSignatureManager(SignatureManager signatureManager);  }
@Test public void testExecuteWithSignatureFilesPresent() { SignatureFileInfo info1 = new SignatureFileInfo(33, false, SignatureType.BINARY); info1.setFile(Paths.get("foo/bar/version_33.xml")); SignatureFileInfo info2 = new SignatureFileInfo(45, false, SignatureType.BINARY); info2.setFile(Paths.get("foo/bar/version_45.xml")); SignatureFileInfo info3 = new SignatureFileInfo(78, true, SignatureType.BINARY); info3.setFile(Paths.get("foo/bar/version_78.xml")); SignatureFileInfo info4 = new SignatureFileInfo(133, false, SignatureType.CONTAINER); info4.setFile(Paths.get("foo/bar/version_133.xml")); SignatureFileInfo info5 = new SignatureFileInfo(145, false, SignatureType.CONTAINER); info5.setFile(Paths.get("foo/bar/version_145.xml")); SortedMap<String, SignatureFileInfo> binSigFiles = new TreeMap<String, SignatureFileInfo>(); binSigFiles.put("33", info1); binSigFiles.put("45", info2); binSigFiles.put("78", info3); SortedMap<String, SignatureFileInfo> containerSigFiles = new TreeMap<String, SignatureFileInfo>(); binSigFiles.put("133", info4); binSigFiles.put("145", info5); Map<SignatureType, SortedMap<String, SignatureFileInfo>> availableFiles = new HashMap<SignatureType, SortedMap<String,SignatureFileInfo>>(); availableFiles.put(SignatureType.BINARY, binSigFiles); availableFiles.put(SignatureType.CONTAINER, containerSigFiles); when(signatureManager.getAvailableSignatureFiles()).thenReturn(availableFiles); command.execute(); verify(printWriter).println("Type: Binary Version: 33 File name: version_33.xml"); verify(printWriter).println("Type: Binary Version: 45 File name: version_45.xml"); verify(printWriter).println("Type: Binary Version: 78 File name: version_78.xml"); verify(printWriter).println("Type: Container Version: 133 File name: version_133.xml"); verify(printWriter).println("Type: Container Version: 145 File name: version_145.xml"); }
@Test public void testExecuteWithNoSignatureFilesPresent() { when(signatureManager.getAvailableSignatureFiles()).thenReturn(Collections.EMPTY_MAP); command.execute(); verify(printWriter).println("No signature files available"); }