### Question:
AwsInstanceView { public int getOnDemandPercentage() { return HUNDRED_PERCENT - Objects.requireNonNullElse(getSpotPercentage(), 0); } AwsInstanceView(InstanceTemplate instanceTemplate); List<Volume> getVolumes(); String getFlavor(); String getGroupName(); Long getPrivateId(); Long getTemplateId(); boolean isEncryptedVolumes(); boolean isKmsEnabled(); boolean isKmsDefault(); boolean isKmsCustom(); String getKmsKey(); Integer getSpotPercentage(); Double getSpotMaxPrice(); int getOnDemandPercentage(); boolean isFastEbsEncryptionEnabled();  }### Answer:
@Test public void testOnDemand() { Map<String, Object> map = new HashMap<>(); map.put(AwsInstanceTemplate.EC2_SPOT_PERCENTAGE, 30); InstanceTemplate instanceTemplate = new InstanceTemplate("", "", 0L, Collections.emptyList(), InstanceStatus.STARTED, map, 0L, IMAGE_ID); AwsInstanceView actual = new AwsInstanceView(instanceTemplate); assertThat(actual.getOnDemandPercentage()).isEqualTo(70); }
@Test public void testOnDemandMissingPercentage() { InstanceTemplate instanceTemplate = new InstanceTemplate("", "", 0L, Collections.emptyList(), InstanceStatus.STARTED, Map.of(), 0L, IMAGE_ID); AwsInstanceView actual = new AwsInstanceView(instanceTemplate); assertThat(actual.getOnDemandPercentage()).isEqualTo(100); }