Open Kilda Java Documentation
TestConfig.java
Go to the documentation of this file.
1 /* Copyright 2017 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.northbound.controller;
17 
18 import static org.mockito.Mockito.mock;
19 
28 
29 import org.springframework.boot.test.context.TestConfiguration;
30 import org.springframework.context.annotation.Bean;
31 import org.springframework.context.annotation.ComponentScan;
32 import org.springframework.context.annotation.Configuration;
33 import org.springframework.context.annotation.FilterType;
34 import org.springframework.context.annotation.Import;
35 import org.springframework.context.annotation.PropertySource;
36 import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
37 import org.springframework.web.client.RestTemplate;
38 
39 import java.util.Map;
40 
44 @Configuration
45 @EnableWebSecurity
46 @Import({WebConfig.class, SecurityConfig.class, KafkaConfig.class})
47 @ComponentScan(
48  basePackages = {
49  "org.openkilda.northbound.controller",
50  "org.openkilda.northbound.converter",
51  "org.openkilda.northbound.service",
52  "org.openkilda.northbound.utils"
53  },
54  excludeFilters = {
55  @ComponentScan.Filter(type = FilterType.ANNOTATION, value = TestConfiguration.class)
56  })
57 @PropertySource({"classpath:northbound.properties"})
58 public class TestConfig {
59  @Bean
61  return new TestMessageMock();
62  }
63 
64  @Bean
66  return new TestMessageMock();
67  }
68 
69  @Bean
71  return new TestHealthCheckMessageMock();
72  }
73 
74  @Bean
75  public RestTemplate restTemplate() {
76  return mock(RestTemplate.class);
77  }
78 
79  @Bean
81  return new TestCorrelationIdFactory();
82  }
83 
84  private class TestHealthCheckMessageMock implements HealthCheckMessageConsumer {
85 
86  @Override
87  public Map<String, String> poll(String correlationId) {
88  return null;
89  }
90 
91  @Override
92  public void clear() {
93 
94  }
95  }
96 }
value
Definition: nodes.py:62
HealthCheckMessageConsumer healthCheckMessageConsumer()
Definition: TestConfig.java:70