### Question:
InstanceOfferManager { public boolean isInstanceAllowed(final String instanceType, final Long regionId, final boolean spot) { return isInstanceTypeAllowed(instanceType, null, defaultRegionIfNull(regionId), INSTANCE_TYPES_PREFERENCES, spot); }  @PostConstruct void init(); void updateOfferedInstanceTypes(final List<InstanceType> instanceTypes); void updateOfferedInstanceTypes(); void updateOfferedInstanceTypesAccordingToInstanceOffers(final List<InstanceOffer> instanceOffers); Date getPriceListPublishDate(); InstancePrice getInstanceEstimatedPrice(Long id, String version, String configName,
            String instanceType, int instanceDisk, Boolean spot, Long regionId); InstancePrice getInstanceEstimatedPrice(
            String instanceType, int instanceDisk, Boolean spot, Long regionId); PipelineRunPrice getPipelineRunEstimatedPrice(Long runId, Long regionId); List<InstanceType> getAllowedInstanceTypes(); List<InstanceType> getAllowedInstanceTypes(final Long regionId, final Boolean spot); List<InstanceType> getAllowedToolInstanceTypes(final Long regionId, final Boolean spot); double getPricePerHourForInstance(final String instanceType, final Long regionId); boolean isInstanceAllowed(final String instanceType, final Long regionId, final boolean spot); boolean isToolInstanceAllowed(final String instanceType,
                                         final ContextualPreferenceExternalResource toolResource,
                                         final Long regionId,
                                         final boolean spot); boolean isToolInstanceAllowedInAnyRegion(final String instanceType,
                                                    final ContextualPreferenceExternalResource toolResource); boolean isPriceTypeAllowed(final String priceType,
                                      final ContextualPreferenceExternalResource toolResource,
                                      final boolean isMaster); boolean isPriceTypeAllowed(final String priceType,
                                      final ContextualPreferenceExternalResource toolResource); @Transactional(propagation = Propagation.REQUIRED) void refreshPriceList(); @Transactional(propagation = Propagation.REQUIRED) List<InstanceOffer> updatePriceListForRegion(AbstractCloudRegion cloudRegion); List<InstanceType> getAllInstanceTypes(); List<InstanceType> getAllInstanceTypes(final Long regionId, final boolean spot); Observable<List<InstanceType>> getAllInstanceTypesObservable(); AllowedInstanceAndPriceTypes getAllowedInstanceAndPriceTypes(final Long toolId, final Long regionId,
                                                                        final Boolean spot);  }### Answer:
@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class) public void testUpdateAllowedInstanceTypes() { Preference allowedTypesPreference = SystemPreferences.CLUSTER_ALLOWED_INSTANCE_TYPES.toPreference(); allowedTypesPreference.setValue(M5_PATTERN); preferenceManager.update(Collections.singletonList(allowedTypesPreference)); Assert.assertTrue(instanceOfferManager.isInstanceAllowed(M5_INSTANCE_TYPE, region.getId(), false)); Assert.assertFalse(instanceOfferManager.isInstanceAllowed(X5_INSTANCE_TYPE, region.getId(), false)); allowedTypesPreference.setValue(M5_X5_PATTERN); preferenceManager.update(Collections.singletonList(allowedTypesPreference)); Assert.assertTrue(instanceOfferManager.isInstanceAllowed(M5_INSTANCE_TYPE, region.getId(), false)); Assert.assertTrue(instanceOfferManager.isInstanceAllowed(X5_INSTANCE_TYPE, region.getId(), false)); }