@Test
 public void removeConnection() throws Exception {
   ConnectionFactoryRegistry connectionFactoryLocator = new ConnectionFactoryRegistry();
   ConnectionFactory<TestApi2> connectionFactory =
       new StubOAuth2ConnectionFactory("clientId", "clientSecret", THROW_EXCEPTION);
   connectionFactoryLocator.addConnectionFactory(connectionFactory);
   StubConnectionRepository connectionRepository = new StubConnectionRepository();
   connectionRepository.addConnection(
       connectionFactory.createConnection(
           new ConnectionData(
               "oauth2Provider", "provider1User1", null, null, null, null, null, null, null)));
   connectionRepository.addConnection(
       connectionFactory.createConnection(
           new ConnectionData(
               "oauth2Provider", "provider1User2", null, null, null, null, null, null, null)));
   assertEquals(2, connectionRepository.findConnections("oauth2Provider").size());
   ConnectController connectController =
       new ConnectController(connectionFactoryLocator, connectionRepository);
   List<DisconnectInterceptor<?>> interceptors = getDisconnectInterceptor();
   connectController.setDisconnectInterceptors(interceptors);
   MockMvc mockMvc = standaloneSetup(connectController).build();
   mockMvc
       .perform(delete("/connect/oauth2Provider/provider1User1"))
       .andExpect(redirectedUrl("/connect/oauth2Provider"));
   assertEquals(1, connectionRepository.findConnections("oauth2Provider").size());
   assertFalse(((TestConnectInterceptor<?>) (interceptors.get(0))).preDisconnectInvoked);
   assertFalse(((TestConnectInterceptor<?>) (interceptors.get(0))).postDisconnectInvoked);
   assertNull(((TestConnectInterceptor<?>) (interceptors.get(0))).connectionFactory);
   assertTrue(((TestConnectInterceptor<?>) (interceptors.get(1))).preDisconnectInvoked);
   assertTrue(((TestConnectInterceptor<?>) (interceptors.get(1))).postDisconnectInvoked);
   assertSame(
       connectionFactory, ((TestConnectInterceptor<?>) (interceptors.get(1))).connectionFactory);
 }
Exemplo n.º 2
0
 @Test
 public void first() {
   final List<String> values = asList("a", "b", "a", "c", "a", "d", "e");
   assertEquals("c", Algorithms.first(values, Conditions.eq("c")));
   assertEquals("a", Algorithms.first(values, Conditions.eq("a")));
   assertEquals("e", Algorithms.first(values, Conditions.eq("e")));
   assertNull(Algorithms.first(values, Conditions.eq("f")));
 }
 @Test
 public void
     getMergedAnnotationAttributesOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() {
   AnnotationAttributes attributes =
       getMergedAnnotationAttributes(MetaCycleAnnotatedClass.class, TX_NAME);
   assertNull(
       "Should not find annotation attributes for @Transactional on MetaCycleAnnotatedClass",
       attributes);
 }
 /**
  * {@code AbstractClassWithInheritedAnnotation} declares {@code handleParameterized(T)}; whereas,
  * {@code ConcreteClassWithInheritedAnnotation} declares {@code handleParameterized(String)}.
  *
  * <p>As of Spring 4.2, {@code AnnotatedElementUtils.processWithFindSemantics()} does not resolve
  * an <em>equivalent</em> method in {@code AbstractClassWithInheritedAnnotation} for the
  * <em>bridged</em> {@code handleParameterized(String)} method.
  *
  * @since 4.2
  */
 @Test
 public void findMergedAnnotationAttributesInheritedFromBridgedMethod()
     throws NoSuchMethodException {
   Method method =
       ConcreteClassWithInheritedAnnotation.class.getMethod("handleParameterized", String.class);
   AnnotationAttributes attributes = findMergedAnnotationAttributes(method, Transactional.class);
   assertNull(
       "Should not find @Transactional on bridged ConcreteClassWithInheritedAnnotation.handleParameterized()",
       attributes);
 }
 @Test
 public void getMergedAnnotationAttributesFromInterfaceImplementedBySuperclass() {
   Class<?> element = ConcreteClassWithInheritedAnnotation.class;
   String name = TX_NAME;
   AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
   assertNull(
       "Should not find @Transactional on ConcreteClassWithInheritedAnnotation", attributes);
   // Verify contracts between utility methods:
   assertFalse(isAnnotated(element, name));
 }
Exemplo n.º 6
0
 @Mock
 public String getConfig(Invocation inv) {
   String config = inv.proceed();
   assertNull(config);
   return "test";
 }
 @Test
 public void getMetaAnnotationTypesOnNonAnnotatedClass() {
   assertNull(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class));
 }
 @Test
 public void getAllAnnotationAttributesOnNonAnnotatedClass() {
   assertNull(getAllAnnotationAttributes(NonAnnotatedClass.class, TX_NAME));
 }