@Test public void convertSpecKeepsAllData() { com.squareup.okhttp.ConnectionSpec squareSpec = com.squareup.okhttp.ConnectionSpec.MODERN_TLS; ConnectionSpec spec = Utils.convertSpec(squareSpec); List<com.squareup.okhttp.TlsVersion> squareTlsVersions = squareSpec.tlsVersions(); List<TlsVersion> tlsVersions = spec.tlsVersions(); int versionsSize = squareTlsVersions.size(); List<com.squareup.okhttp.CipherSuite> squareCipherSuites = squareSpec.cipherSuites(); List<CipherSuite> cipherSuites = spec.cipherSuites(); int cipherSuitesSize = squareCipherSuites.size(); assertTrue(spec.isTls()); assertTrue(spec.supportsTlsExtensions()); assertEquals(versionsSize, tlsVersions.size()); for (int i = 0; i < versionsSize; i++) { assertEquals(TlsVersion.forJavaName(squareTlsVersions.get(i).javaName()), tlsVersions.get(i)); } assertEquals(cipherSuitesSize, cipherSuites.size()); for (int i = 0; i < cipherSuitesSize; i++) { assertEquals(CipherSuite.forJavaName(squareCipherSuites.get(i).name()), cipherSuites.get(i)); } }
static ConnectionSpec convertSpec(com.squareup.okhttp.ConnectionSpec spec) { Preconditions.checkArgument(spec.isTls(), "plaintext ConnectionSpec is not accepted"); List<com.squareup.okhttp.TlsVersion> tlsVersionList = spec.tlsVersions(); String[] tlsVersions = new String[tlsVersionList.size()]; for (int i = 0; i < tlsVersions.length; i++) { tlsVersions[i] = tlsVersionList.get(i).javaName(); } List<com.squareup.okhttp.CipherSuite> cipherSuiteList = spec.cipherSuites(); CipherSuite[] cipherSuites = new CipherSuite[cipherSuiteList.size()]; for (int i = 0; i < cipherSuites.length; i++) { cipherSuites[i] = CipherSuite.valueOf(cipherSuiteList.get(i).name()); } return new ConnectionSpec.Builder(spec.isTls()) .supportsTlsExtensions(spec.supportsTlsExtensions()) .tlsVersions(tlsVersions) .cipherSuites(cipherSuites) .build(); }
Utils { static ConnectionSpec convertSpec(com.squareup.okhttp.ConnectionSpec spec) { Preconditions.checkArgument(spec.isTls(), "plaintext ConnectionSpec is not accepted"); List<com.squareup.okhttp.TlsVersion> tlsVersionList = spec.tlsVersions(); String[] tlsVersions = new String[tlsVersionList.size()]; for (int i = 0; i < tlsVersions.length; i++) { tlsVersions[i] = tlsVersionList.get(i).javaName(); } List<com.squareup.okhttp.CipherSuite> cipherSuiteList = spec.cipherSuites(); CipherSuite[] cipherSuites = new CipherSuite[cipherSuiteList.size()]; for (int i = 0; i < cipherSuites.length; i++) { cipherSuites[i] = CipherSuite.valueOf(cipherSuiteList.get(i).name()); } return new ConnectionSpec.Builder(spec.isTls()) .supportsTlsExtensions(spec.supportsTlsExtensions()) .tlsVersions(tlsVersions) .cipherSuites(cipherSuites) .build(); } }
Utils { static ConnectionSpec convertSpec(com.squareup.okhttp.ConnectionSpec spec) { Preconditions.checkArgument(spec.isTls(), "plaintext ConnectionSpec is not accepted"); List<com.squareup.okhttp.TlsVersion> tlsVersionList = spec.tlsVersions(); String[] tlsVersions = new String[tlsVersionList.size()]; for (int i = 0; i < tlsVersions.length; i++) { tlsVersions[i] = tlsVersionList.get(i).javaName(); } List<com.squareup.okhttp.CipherSuite> cipherSuiteList = spec.cipherSuites(); CipherSuite[] cipherSuites = new CipherSuite[cipherSuiteList.size()]; for (int i = 0; i < cipherSuites.length; i++) { cipherSuites[i] = CipherSuite.valueOf(cipherSuiteList.get(i).name()); } return new ConnectionSpec.Builder(spec.isTls()) .supportsTlsExtensions(spec.supportsTlsExtensions()) .tlsVersions(tlsVersions) .cipherSuites(cipherSuites) .build(); } private  Utils(); }
Utils { static ConnectionSpec convertSpec(com.squareup.okhttp.ConnectionSpec spec) { Preconditions.checkArgument(spec.isTls(), "plaintext ConnectionSpec is not accepted"); List<com.squareup.okhttp.TlsVersion> tlsVersionList = spec.tlsVersions(); String[] tlsVersions = new String[tlsVersionList.size()]; for (int i = 0; i < tlsVersions.length; i++) { tlsVersions[i] = tlsVersionList.get(i).javaName(); } List<com.squareup.okhttp.CipherSuite> cipherSuiteList = spec.cipherSuites(); CipherSuite[] cipherSuites = new CipherSuite[cipherSuiteList.size()]; for (int i = 0; i < cipherSuites.length; i++) { cipherSuites[i] = CipherSuite.valueOf(cipherSuiteList.get(i).name()); } return new ConnectionSpec.Builder(spec.isTls()) .supportsTlsExtensions(spec.supportsTlsExtensions()) .tlsVersions(tlsVersions) .cipherSuites(cipherSuites) .build(); } private  Utils(); static Metadata convertHeaders(List<Header> http2Headers); static Metadata convertTrailers(List<Header> http2Headers); }
Utils { static ConnectionSpec convertSpec(com.squareup.okhttp.ConnectionSpec spec) { Preconditions.checkArgument(spec.isTls(), "plaintext ConnectionSpec is not accepted"); List<com.squareup.okhttp.TlsVersion> tlsVersionList = spec.tlsVersions(); String[] tlsVersions = new String[tlsVersionList.size()]; for (int i = 0; i < tlsVersions.length; i++) { tlsVersions[i] = tlsVersionList.get(i).javaName(); } List<com.squareup.okhttp.CipherSuite> cipherSuiteList = spec.cipherSuites(); CipherSuite[] cipherSuites = new CipherSuite[cipherSuiteList.size()]; for (int i = 0; i < cipherSuites.length; i++) { cipherSuites[i] = CipherSuite.valueOf(cipherSuiteList.get(i).name()); } return new ConnectionSpec.Builder(spec.isTls()) .supportsTlsExtensions(spec.supportsTlsExtensions()) .tlsVersions(tlsVersions) .cipherSuites(cipherSuites) .build(); } private  Utils(); static Metadata convertHeaders(List<Header> http2Headers); static Metadata convertTrailers(List<Header> http2Headers);  }