### Question:
RunConfigurationProvider implements ConfigurationProvider<RunConfigurationEntry,
        CloudPlatformPreferences> { @Override public void validateEntry(RunConfigurationEntry entry) { if (entry.getPipelineId() != null) { pipelineManager.load(entry.getPipelineId()); } else if (entry.getConfiguration() != null) { validateEntryConfiguration(entry.getConfiguration()); } }  @Override ExecutionEnvironment getExecutionEnvironment(); @Override boolean hasNoPermission(RunConfigurationEntry entry, String permissionName); @Override List<RunConfigurationEntry> mergeConfigurationEntries(List<RunConfigurationEntry> entries,
                                                                 List<RunConfigurationEntry> dbEntries); @Override void validateEntry(RunConfigurationEntry entry); @Override List<PipelineRun> runAnalysis(AnalysisConfiguration<RunConfigurationEntry> configuration); @Override boolean stop(Long runId, CloudPlatformPreferences executionPreferences);  }### Answer:
@Test public void validateShouldValidateConfigurationInstanceType() { final PipelineConfiguration pipelineConfiguration = new PipelineConfiguration(); pipelineConfiguration.setCloudRegionId(REGION_ID); pipelineConfiguration.setInstanceType(ALLOWED_INSTANCE_TYPE); final RunConfigurationEntry runConfigurationEntry = new RunConfigurationEntry(); runConfigurationEntry.setConfiguration(pipelineConfiguration); runConfigurationProvider.validateEntry(runConfigurationEntry); verify(instanceOfferManager).isToolInstanceAllowed(eq(ALLOWED_INSTANCE_TYPE), any(), eq(REGION_ID), eq(false)); }
@Test public void validateShouldNotValidateInstanceTypeIfConfigurationInstanceTypeIsNotSpecified() { final PipelineConfiguration pipelineConfiguration = new PipelineConfiguration(); pipelineConfiguration.setCloudRegionId(REGION_ID); pipelineConfiguration.setInstanceType(null); final RunConfigurationEntry runConfigurationEntry = new RunConfigurationEntry(); runConfigurationEntry.setConfiguration(pipelineConfiguration); runConfigurationProvider.validateEntry(runConfigurationEntry); verify(instanceOfferManager, times(0)).isToolInstanceAllowed(any(), any(), eq(REGION_ID), eq(false)); }
@Test public void validateShouldUseToolResourceWhileCheckingToolAllowedIfDockerImageIsSpecified() { final PipelineConfiguration pipelineConfiguration = new PipelineConfiguration(); pipelineConfiguration.setCloudRegionId(REGION_ID); pipelineConfiguration.setInstanceType(ALLOWED_INSTANCE_TYPE); pipelineConfiguration.setDockerImage(TOOL_IMAGE); final RunConfigurationEntry runConfigurationEntry = new RunConfigurationEntry(); runConfigurationEntry.setConfiguration(pipelineConfiguration); runConfigurationProvider.validateEntry(runConfigurationEntry); verify(instanceOfferManager).isToolInstanceAllowed(any(), eq(TOOL_RESOURCE), eq(REGION_ID), eq(false)); }
@Test public void validateShouldFailIfConfigurationInstanceTypeIsNotAllowed() { final PipelineConfiguration pipelineConfiguration = new PipelineConfiguration(); pipelineConfiguration.setCloudRegionId(REGION_ID); pipelineConfiguration.setInstanceType(NOT_ALLOWED_INSTANCE_TYPE); final RunConfigurationEntry runConfigurationEntry = new RunConfigurationEntry(); runConfigurationEntry.setConfiguration(pipelineConfiguration); assertThrows(IllegalArgumentException.class, () -> runConfigurationProvider.validateEntry(runConfigurationEntry)); verify(instanceOfferManager) .isToolInstanceAllowed(eq(NOT_ALLOWED_INSTANCE_TYPE), any(), eq(REGION_ID), eq(false)); }
@Test public void validateShouldUseNoRegionWhileCheckingToolAllowedIfNoRegionIsSpecified() { final PipelineConfiguration pipelineConfiguration = new PipelineConfiguration(); pipelineConfiguration.setCloudRegionId(NO_REGION); pipelineConfiguration.setInstanceType(ALLOWED_INSTANCE_TYPE); final RunConfigurationEntry runConfigurationEntry = new RunConfigurationEntry(); runConfigurationEntry.setConfiguration(pipelineConfiguration); runConfigurationProvider.validateEntry(runConfigurationEntry); verify(instanceOfferManager).isToolInstanceAllowed(eq(ALLOWED_INSTANCE_TYPE), any(), eq(NO_REGION), eq(false)); }