Provisioner { List<Provision> parseProvisions(List<ProvisionPlaintext> provisionPlaintexts) { List<Provision> provisions = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); if (provisionPlaintexts != null) { for (ProvisionPlaintext provisionPlaintext : provisionPlaintexts) { Provision provision = new Provision(); provision.setProvisonPath(provisionPlaintext.getProvisionPath()); try { provision.setRepositoryProvision( mapper.readValue(provisionPlaintext.getRepositoryProvision(), RepositoryProvision.class)); provisions.add(provision); } catch (IOException e) { Utils.debugLog(TAG, "could not parse repository provision", e); } } } return provisions; } protected  Provisioner();  static final String TAG; }
@Test public void parseProvisions() { List<Provisioner.ProvisionPlaintext> plaintexts = Arrays.asList(new Provisioner.ProvisionPlaintext(), new Provisioner.ProvisionPlaintext()); plaintexts.get(0).setProvisionPath("/some/dir/abc.fdrp"); plaintexts.get(0).setRepositoryProvision("{\"username\": \"user1\", \"password\": \"secret1\", \"name\": \"test repo a\", \"url\": \"https: plaintexts.get(1).setProvisionPath("/some/dir/def.fdrp"); plaintexts.get(1).setRepositoryProvision("{\"username\": \"user2\", \"name\": \"test repo a\", \"password\": \"other secret\", \"url\": \"https: Provisioner p = new Provisioner(); List<Provisioner.Provision> result = p.parseProvisions(plaintexts); Assert.assertEquals("/some/dir/abc.fdrp", result.get(0).getProvisonPath()); Assert.assertEquals("test repo a", result.get(0).getRepositoryProvision().getName()); Assert.assertEquals("https: Assert.assertEquals("1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff", result.get(0).getRepositoryProvision().getSigfp()); Assert.assertEquals("user1", result.get(0).getRepositoryProvision().getUsername()); Assert.assertEquals("secret1", result.get(0).getRepositoryProvision().getPassword()); Assert.assertEquals("/some/dir/def.fdrp", result.get(1).getProvisonPath()); Assert.assertEquals("test repo a", result.get(1).getRepositoryProvision().getName()); Assert.assertEquals("https: Assert.assertEquals("1111222233334444555566667777888899990000aaaabbbbccccddddeeeeffff", result.get(1).getRepositoryProvision().getSigfp()); Assert.assertEquals("user2", result.get(1).getRepositoryProvision().getUsername()); Assert.assertEquals("other secret", result.get(1).getRepositoryProvision().getPassword()); }