コード例 #1
0
  public void testViewRecursion() throws JavaModelException, PartInitException {
    view = (ActiveSearchView) JavaPlugin.getActivePage().showView(ActiveSearchView.ID);
    ActiveSearchView.getFromActivePerspective().setSyncExecForTesting(false);

    for (AbstractRelationProvider provider :
        ContextCorePlugin.getDefault().getRelationProviders()) {
      assertTrue(provider.isEnabled());
    }
    assertEquals(0, view.getViewer().getTree().getItemCount());

    IWorkbenchPart part =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
    IMethod m1 = type1.createMethod("void m1() {\n m1(); \n}", null, true, null);
    StructuredSelection sm1 = new StructuredSelection(m1);
    monitor.selectionChanged(part, sm1);
    IInteractionElement node =
        manager.processInteractionEvent(
            mockInterestContribution(m1.getHandleIdentifier(), scaling.getLandmark()));

    assertEquals(1, ContextCore.getContextManager().getActiveLandmarks().size());

    assertEquals(1, search(2, node).size());

    List<TreeItem> collectedItems = new ArrayList<TreeItem>();
    UiTestUtil.collectTreeItemsInView(view.getViewer().getTree().getItems(), collectedItems);

    // just make sure that the view didn't blow up.
    assertEquals(1, collectedItems.size());
    monitor.selectionChanged(part, sm1);
    manager.processInteractionEvent(
        mockInterestContribution(m1.getHandleIdentifier(), -scaling.getLandmark()));
  }
コード例 #2
0
  public void testSearchAfterDeletion()
      throws JavaModelException, PartInitException, IOException, CoreException {
    view = (ActiveSearchView) JavaPlugin.getActivePage().showView(ActiveSearchView.ID);
    if (view != null) {
      assertEquals(0, view.getViewer().getTree().getItemCount());

      IWorkbenchPart part =
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
      IMethod m1 = type1.createMethod("void m1() {\n m2() \n}", null, true, null);
      IMethod m2 = type1.createMethod("void m2() { }", null, true, null);
      StructuredSelection sm2 = new StructuredSelection(m2);
      monitor.selectionChanged(part, sm2);
      IInteractionElement node =
          manager.processInteractionEvent(
              mockInterestContribution(m2.getHandleIdentifier(), scaling.getLandmark()));
      assertEquals(1, ContextCore.getContextManager().getActiveLandmarks().size());

      assertEquals(1, search(2, node).size());

      m1.delete(true, null);
      assertFalse(m1.exists());

      assertEquals(0, search(2, node).size());
    }
  }
 @Test
 public void shouldCreateResourceMethodWithBeanParamAnnotatedParameter()
     throws JavaModelException, CoreException {
   // pre-conditions
   final IType carType =
       metamodelMonitor.resolveType("org.jboss.tools.ws.jaxrs.sample.services.CarResource");
   replaceAllOccurrencesOfCode(
       carType,
       "update(final CarParameterAggregator car)",
       "update(@BeanParam final CarParameterAggregator car)",
       false);
   assertThat(carType, notNullValue());
   final IMethod carMethod = JavaElementsUtils.getMethod(carType, "update");
   assertThat(carMethod, notNullValue());
   // operation
   final List<IJaxrsElement> elements =
       JaxrsElementFactory.createElements(
           carType,
           JdtUtils.parse(carType, new NullProgressMonitor()),
           metamodel,
           new NullProgressMonitor());
   // verifications
   assertThat(elements.size(), equalTo(3));
   final JaxrsResource carResource = metamodel.findResource(carType);
   final JaxrsResourceMethod resourceMethod =
       carResource.getMethods().get(carMethod.getHandleIdentifier());
   assertThat(resourceMethod.getJavaMethodParameters().size(), equalTo(1));
   assertThat(
       resourceMethod
           .getJavaMethodParameters()
           .iterator()
           .next()
           .getAnnotation(JaxrsClassnames.BEAN_PARAM),
       notNullValue());
 }
コード例 #4
0
  public void testParentResourceMapping() throws CoreException {
    IWorkbenchPart part =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
    IMethod m1 = type1.createMethod("public void m1() { }", null, true, null);

    monitor.selectionChanged(part, new StructuredSelection(m1));
    IInteractionElement m1Node =
        ContextCore.getContextManager().getElement(m1.getHandleIdentifier());
    assertTrue(m1Node.getInterest().isInteresting());

    IResource containingResource =
        ResourcesUiBridgePlugin.getDefault().getResourceForElement(m1Node, true);
    assertEquals(m1.getCompilationUnit().getAdapter(IResource.class), containingResource);
  }