RemoteCertificateConverter { public static List<CertificateToken> toCertificateTokens(List<RemoteCertificate> remoteCertificates) { if (Utils.isCollectionNotEmpty(remoteCertificates)) { List<CertificateToken> certificateTokens = new LinkedList<>(); for (RemoteCertificate remoteCertificate : remoteCertificates) { CertificateToken certificateToken = toCertificateToken(remoteCertificate); if (certificateToken != null) { certificateTokens.add(certificateToken); } } return certificateTokens; } return null; }  static CertificateToken toCertificateToken(RemoteCertificate remoteCertificate); static RemoteCertificate toRemoteCertificate(CertificateToken certificate); static List<CertificateToken> toCertificateTokens(List<RemoteCertificate> remoteCertificates);  }
@Test public void toCertificateTokens() { List<RemoteCertificate> remoteCertificates = new ArrayList<>(); remoteCertificates.add(new RemoteCertificate(encodedCertificate)); remoteCertificates.add(new RemoteCertificate(null)); remoteCertificates.add(null); List<CertificateToken> certificateTokens = RemoteCertificateConverter.toCertificateTokens(remoteCertificates); assertEquals(1, certificateTokens.size()); assertTrue(Arrays.equals(certificateTokens.get(0).getEncoded(), remoteCertificates.get(0).getEncodedCertificate())); }