### Question:
StackUtil { public long getUptimeForCluster(Cluster cluster, boolean addUpsinceToUptime) { Duration uptime = Duration.ZERO; if (StringUtils.isNotBlank(cluster.getUptime())) { uptime = Duration.parse(cluster.getUptime()); } if (cluster.getUpSince() != null && addUpsinceToUptime) { long now = new Date().getTime(); uptime = uptime.plusMillis(now - cluster.getUpSince()); } return uptime.toMillis(); }  Set<Node> collectNodes(Stack stack); Set<Node> collectReachableNodes(Stack stack); Set<Node> collectNodesFromHostnames(Stack stack, Set<String> hostnames); Set<Node> collectNodesWithDiskData(Stack stack); Set<Node> collectNewNodesWithDiskData(Stack stack, Set<String> newNodeAddresses); String extractClusterManagerIp(StackView stackView); String extractClusterManagerIp(Stack stack); String extractClusterManagerAddress(Stack stack); long getUptimeForCluster(Cluster cluster, boolean addUpsinceToUptime); CloudCredential getCloudCredential(Stack stack);  }### Answer:
@Test public void testGetUptimeForClusterZero() { Cluster cluster = new Cluster(); cluster.setStatus(Status.CREATE_IN_PROGRESS); long uptime = stackUtil.getUptimeForCluster(cluster, true); assertEquals(0L, uptime); }
@Test public void testGetUptimeForClusterNoGetUpSince() { Cluster cluster = new Cluster(); int minutes = 10; cluster.setUptime(Duration.ofMinutes(minutes).toString()); long uptime = stackUtil.getUptimeForCluster(cluster, false); assertEquals(Duration.ofMinutes(minutes).toMillis(), uptime); }
@Test public void testGetUptimeForCluster() { Cluster cluster = new Cluster(); int minutes = 10; cluster.setUptime(Duration.ofMinutes(minutes).toString()); cluster.setStatus(Status.AVAILABLE); cluster.setUpSince(new Date().getTime()); long uptime = stackUtil.getUptimeForCluster(cluster, true); assertTrue(uptime >= Duration.ofMinutes(minutes).toMillis()); }