### Question:
PackageVersionChecker { public CheckResult checkInstancesHaveAllMandatoryPackageVersion(Set<InstanceMetaData> instanceMetaDataSet) { Map<String, List<String>> instancesWithMissingPackageVersions = instanceMetadataUpdater.collectInstancesWithMissingPackageVersions(instanceMetaDataSet); if (!instancesWithMissingPackageVersions.isEmpty()) { String message = messagesService.getMessage(CLUSTER_PACKAGE_VERSIONS_ON_INSTANCES_ARE_MISSING.getMessage(), Collections.singletonList(instancesWithMissingPackageVersions.entrySet().stream() .map(entry -> String.format("Instance ID: [%s] Packages without version: [%s]", entry.getKey(), StringUtils.join(entry.getValue(), ","))) .collect(Collectors.joining(" * ")))); return CheckResult.failed(message); } return CheckResult.ok(); }  CheckResult compareImageAndInstancesMandatoryPackageVersion(StatedImage newImage, Set<InstanceMetaData> instanceMetaDataSet); CheckResult checkInstancesHaveAllMandatoryPackageVersion(Set<InstanceMetaData> instanceMetaDataSet); CheckResult checkInstancesHaveMultiplePackageVersions(Set<InstanceMetaData> instanceMetaDataSet); static final String SALT_BOOTSTRAP; }### Answer:
@Test public void checkInstancesHaveAllMandatoryPackageVersionOk() { when(instanceMetadataUpdater.collectInstancesWithMissingPackageVersions(anySet())).thenReturn(Collections.emptyMap()); CheckResult result = underTest.checkInstancesHaveAllMandatoryPackageVersion(Collections.emptySet()); assertEquals(EventStatus.OK, result.getStatus()); }
@Test public void checkInstancesHaveAllMandatoryPackageVersionNok() { when(instanceMetadataUpdater.collectInstancesWithMissingPackageVersions(anySet())) .thenReturn(Collections.singletonMap("instance", Collections.singletonList("package"))); CheckResult result = underTest.checkInstancesHaveAllMandatoryPackageVersion(Collections.emptySet()); assertEquals(EventStatus.FAILED, result.getStatus()); }