use of org.eclipse.che.workspace.infrastructure.openshift.server.OpenShiftServerResolverFactory in project che-server by eclipse-che.
the class OpenShiftInternalRuntimeTest method setup.
@BeforeMethod
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
when(startSynchronizerFactory.create(any())).thenReturn(startSynchronizer);
serverResolverFactory = new OpenShiftServerResolverFactory("che-host", MULTI_HOST_STRATEGY, WorkspaceExposureType.NATIVE.getConfigValue());
internalRuntime = new OpenShiftInternalRuntime(13, 5, new URLRewriter.NoOpURLRewriter(), unrecoverablePodEventListenerFactory, serverCheckerFactory, volumesStrategy, probesScheduler, workspaceProbesFactory, new RuntimeEventsPublisher(eventService), mock(KubernetesSharedPool.class), runtimeStateCache, machinesCache, startSynchronizerFactory, ImmutableSet.of(internalEnvironmentProvisioner), kubernetesEnvironmentProvisioner, toolingProvisioner, runtimeHangingDetector, previewUrlCommandProvisioner, secretAsContainerResourceProvisioner, serverResolverFactory, runtimeCleaner, cheNamespace, tracer, context, project);
when(context.getEnvironment()).thenReturn(osEnv);
when(serverCheckerFactory.create(any(), anyString(), any())).thenReturn(serversChecker);
when(context.getIdentity()).thenReturn(IDENTITY);
doNothing().when(project).cleanUp();
when(project.services()).thenReturn(services);
when(project.routes()).thenReturn(routes);
when(project.secrets()).thenReturn(secrets);
when(project.configMaps()).thenReturn(configMaps);
when(project.deployments()).thenReturn(deployments);
doReturn(ImmutableMap.of(M1_NAME, mock(InternalMachineConfig.class), M2_NAME, mock(InternalMachineConfig.class))).when(osEnv).getMachines();
allServices = ImmutableMap.of(SERVICE_NAME, mockService());
allRoutes = ImmutableMap.of(SERVICE_NAME, mockRoute());
final Container container = mockContainer(CONTAINER_NAME_1, EXPOSED_PORT_1, INTERNAL_PORT);
final ImmutableMap<String, Pod> allPods = ImmutableMap.of(POD_NAME, mockPod(ImmutableList.of(container)));
when(services.create(any())).thenAnswer(a -> a.getArguments()[0]);
when(routes.create(any())).thenAnswer(a -> a.getArguments()[0]);
when(deployments.deploy(any(Pod.class))).thenAnswer(a -> a.getArguments()[0]);
when(osEnv.getServices()).thenReturn(allServices);
when(osEnv.getRoutes()).thenReturn(allRoutes);
when(osEnv.getPodsCopy()).thenReturn(allPods);
when(osEnv.getSecrets()).thenReturn(ImmutableMap.of("secret", new Secret()));
when(osEnv.getConfigMaps()).thenReturn(ImmutableMap.of("configMap", new ConfigMap()));
}
use of org.eclipse.che.workspace.infrastructure.openshift.server.OpenShiftServerResolverFactory in project devspaces-images by redhat-developer.
the class OpenShiftInternalRuntimeTest method setup.
@BeforeMethod
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
when(startSynchronizerFactory.create(any())).thenReturn(startSynchronizer);
serverResolverFactory = new OpenShiftServerResolverFactory("che-host", MULTI_HOST_STRATEGY, WorkspaceExposureType.NATIVE.getConfigValue());
internalRuntime = new OpenShiftInternalRuntime(13, 5, new URLRewriter.NoOpURLRewriter(), unrecoverablePodEventListenerFactory, serverCheckerFactory, volumesStrategy, probesScheduler, workspaceProbesFactory, new RuntimeEventsPublisher(eventService), mock(KubernetesSharedPool.class), runtimeStateCache, machinesCache, startSynchronizerFactory, ImmutableSet.of(internalEnvironmentProvisioner), kubernetesEnvironmentProvisioner, toolingProvisioner, runtimeHangingDetector, previewUrlCommandProvisioner, secretAsContainerResourceProvisioner, serverResolverFactory, runtimeCleaner, cheNamespace, tracer, context, project);
when(context.getEnvironment()).thenReturn(osEnv);
when(serverCheckerFactory.create(any(), anyString(), any())).thenReturn(serversChecker);
when(context.getIdentity()).thenReturn(IDENTITY);
doNothing().when(project).cleanUp();
when(project.services()).thenReturn(services);
when(project.routes()).thenReturn(routes);
when(project.secrets()).thenReturn(secrets);
when(project.configMaps()).thenReturn(configMaps);
when(project.deployments()).thenReturn(deployments);
doReturn(ImmutableMap.of(M1_NAME, mock(InternalMachineConfig.class), M2_NAME, mock(InternalMachineConfig.class))).when(osEnv).getMachines();
allServices = ImmutableMap.of(SERVICE_NAME, mockService());
allRoutes = ImmutableMap.of(SERVICE_NAME, mockRoute());
final Container container = mockContainer(CONTAINER_NAME_1, EXPOSED_PORT_1, INTERNAL_PORT);
final ImmutableMap<String, Pod> allPods = ImmutableMap.of(POD_NAME, mockPod(ImmutableList.of(container)));
when(services.create(any())).thenAnswer(a -> a.getArguments()[0]);
when(routes.create(any())).thenAnswer(a -> a.getArguments()[0]);
when(deployments.deploy(any(Pod.class))).thenAnswer(a -> a.getArguments()[0]);
when(osEnv.getServices()).thenReturn(allServices);
when(osEnv.getRoutes()).thenReturn(allRoutes);
when(osEnv.getPodsCopy()).thenReturn(allPods);
when(osEnv.getSecrets()).thenReturn(ImmutableMap.of("secret", new Secret()));
when(osEnv.getConfigMaps()).thenReturn(ImmutableMap.of("configMap", new ConfigMap()));
}
Aggregations