InstallRepositories extends PuppetActivity { @Override public String createPuppetScript(Pool pool, Machine machine) throws Exception { return Mustache.toString(getClass(), REPOSITORIES_TEMPLATE, ImmutableMap.<String, List<Map<String, String>>>of( "repositories", repositoriesAsListOfMaps(pool.getSoftware()))); } InstallRepositories(); @Override String createPuppetScript(Pool pool, Machine machine); static final String REPOSITORIES_TEMPLATE; }
@Test public void testCreatePuppetScript() throws Exception { Repository repository = Repository.builder() .name("bigtop") .addEntry("deb http: .key("-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "Version: GnuPG v1.4.10 (GNU/Linux)\n" + "\n" + "[....]") .createRepository(); Pool pool = mock(Pool.class); when(pool.getSoftware()).thenReturn(Software.builder().repository(repository).createSoftware()); PuppetActivity activity = new InstallRepositories(); String content = activity.createPuppetScript(pool, null); assertThat(content).contains("apt::repository { \"bigtop\":\n" + " content => \"deb http: " key => \"-----BEGIN PGP PUBLIC KEY BLOCK-----\\nVersion: GnuPG v1.4.10 (GNU/Linux)\\n\\n[....]\"\n" + "}"); }