Search in sources :

Example 16 with IRoute

use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.

the class ResourceUtilsTest method routeServiceNameShouldMatchServiceInName.

@Test
public void routeServiceNameShouldMatchServiceInName() {
    // given
    // when
    IRoute route = getRouteFor(SERVICE_42, Arrays.asList(ROUTES));
    // then
    assertThat(route).isEqualTo(ROUTES[1]);
}
Also used : IRoute(com.openshift.restclient.model.route.IRoute) Test(org.junit.Test)

Example 17 with IRoute

use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.

the class OpenShiftDebugModeTest method shouldAddRouteTimeoutIfDoesntExist.

@Test
public void shouldAddRouteTimeoutIfDoesntExist() throws CoreException {
    // given
    IRoute route = createRouteFor(dc, project, connection);
    doReturn(null).when(server).getAttribute(eq(OpenShiftServerUtils.ATTR_DEBUG_ROUTE_TIMEOUT), anyString());
    context.setDebugEnabled(true);
    // when
    debugMode.execute(new NullProgressMonitor());
    // then
    verify(route, atLeastOnce()).setAnnotation(eq(OpenShiftAPIAnnotations.TIMEOUT), anyString());
    // send updated dc
    verify(debugMode, times(1)).send(eq(route), eq(connection), any(IProgressMonitor.class));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IRoute(com.openshift.restclient.model.route.IRoute) Test(org.junit.Test)

Example 18 with IRoute

use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.

the class ServerSettingsWizardPageModelTest method should_return_valid_route_if_initialized_with_invalid_route.

@Test
public void should_return_valid_route_if_initialized_with_invalid_route() {
    // given
    ServerSettingsWizardPageModel model = createModel(ResourceMocks.PROJECT2_SERVICES[1], ResourceMocks.PROJECT3_ROUTES[0], null, Arrays.asList(project1, project3, project4), connection);
    // when
    IRoute route = model.getRoute();
    // then
    assertThat(route).isEqualTo(ResourceMocks.PROJECT2_ROUTES[1]);
}
Also used : IRoute(com.openshift.restclient.model.route.IRoute) ServerSettingsWizardPageModel(org.jboss.tools.openshift.internal.ui.server.ServerSettingsWizardPageModel) Test(org.junit.Test)

Example 19 with IRoute

use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.

the class ServerSettingsWizardPageModelTest method shouldNotifyRoutesMatchingSelectedService.

@Test
public void shouldNotifyRoutesMatchingSelectedService() {
    // given
    List<IRoute> notifiedRoutes = new ArrayList<>();
    model.addPropertyChangeListener(new PropertyChangeListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (ServerSettingsWizardPageModel.PROPERTY_ROUTES.equals(event.getPropertyName())) {
                assertThat(event.getNewValue()).isInstanceOf(List.class);
                notifiedRoutes.addAll((List<IRoute>) event.getNewValue());
            }
        }
    });
    // when
    model.setResource(ResourceMocks.PROJECT3_SERVICES[1]);
    // then
    assertThat(notifiedRoutes).containsOnly(ResourceMocks.PROJECT3_ROUTES[1]);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ArrayList(java.util.ArrayList) IRoute(com.openshift.restclient.model.route.IRoute) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 20 with IRoute

use of com.openshift.restclient.model.route.IRoute in project jbosstools-openshift by jbosstools.

the class ServerSettingsWizardPageModelTest method should_not_set_route_if_setSelecteDefaultRoute_is_false_when_updating_server.

@Test
public void should_not_set_route_if_setSelecteDefaultRoute_is_false_when_updating_server() throws CoreException {
    // given
    model.setSelectDefaultRoute(false);
    IRoute route = model.getRoute();
    assertThat(route).isNotNull();
    // when
    model.updateServer();
    // then
    verify(server, atLeastOnce()).setAttribute(eq(OpenShiftServerUtils.ATTR_ROUTE), isNull(String.class));
    verify(model, atLeastOnce()).updateServer(anyString(), any(IService.class), anyString(), anyString(), anyString(), anyString(), anyString(), isNull(String.class), any(org.eclipse.core.resources.IProject.class));
}
Also used : IRoute(com.openshift.restclient.model.route.IRoute) Matchers.anyString(org.mockito.Matchers.anyString) IService(com.openshift.restclient.model.IService) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Aggregations

IRoute (com.openshift.restclient.model.route.IRoute)34 Test (org.junit.Test)15 IService (com.openshift.restclient.model.IService)10 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 List (java.util.List)6 ResourceKind (com.openshift.restclient.ResourceKind)5 Connection (org.jboss.tools.openshift.core.connection.Connection)5 IProject (com.openshift.restclient.model.IProject)4 IResource (com.openshift.restclient.model.IResource)4 Collection (java.util.Collection)4 CoreException (org.eclipse.core.runtime.CoreException)4 NLS (org.eclipse.osgi.util.NLS)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 AbstractHandler (org.eclipse.core.commands.AbstractHandler)3 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)3 ExecutionException (org.eclipse.core.commands.ExecutionException)3 IStatus (org.eclipse.core.runtime.IStatus)3 ISelection (org.eclipse.jface.viewers.ISelection)3