CommandInstall implements Command { @Override public void execute() { MesosCluster cluster = repository.loadCluster(new MesosClusterContainersFactory()); if (cluster != null) { Marathon marathon = cluster.getMarathon(); if (marathon == null) { throw new MinimesosException("Marathon container is not found in cluster " + cluster.getClusterId()); } String marathonJson; try { marathonJson = getMarathonJson(); } catch (IOException e) { throw new MinimesosException("Failed to read JSON file from path, URL or stdin", e); } if (update) { marathon.updateApp(marathonJson); } else if (isNotBlank(app) || isNotBlank(marathonFile)) { marathon.deployApp(marathonJson); } else if (isNotBlank(group)) { marathon.deployGroup(marathonJson); } else { throw new MinimesosException("Neither app, group, --stdinApp or --stdinGroup is provided"); } } else { throw new MinimesosException("Running cluster is not found"); } }  @Override void execute(); @Override boolean validateParameters(); @Override String getName();  }
@Test public void testInstallMarathonFile() throws IOException { command.marathonFile = "src/test/resources/app.json"; command.execute(); verify(marathon).deployApp(IOUtils.toString(new FileReader(command.marathonFile))); }
@Test public void testInstallMarathonApp() throws IOException { command.app = "src/test/resources/app.json"; command.execute(); verify(marathon).deployApp(IOUtils.toString(new FileReader(command.app))); }
@Test public void testInstallMarathonGroup() throws IOException { command.group = "src/test/resources/group.json"; command.execute(); verify(marathon).deployGroup(IOUtils.toString(new FileReader(command.group))); }