All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.avanza.astrix.test.TestApi Maven / Gradle / Ivy

There is a newer version: 2.0.6
Show newest version
/*
 * Copyright 2014 Avanza Bank AB
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.avanza.astrix.test;

import java.util.stream.Stream;

/**
 * SPI to make test specific implementations of Astrix services ("service beans") available in the service registry managed by an {@link AstrixRule}. 

* * @author Elias Lindholm * */ public interface TestApi { /** * Export all service beans provided by this TestApi. Note that it is NOT possible * to export libraries from a TestApi. * * TestApi specific methods (for instance methods for test-data population) should * be placed directly in the given TestApi class, and NOT exported using this method. * * @param testContext */ void exportServices(TestContext testContext); /** * Returns a Stream of all TestApi's used by this TestApi. When {@link AstrixRule} loads a TestApi * it will also load all its dependencies. * * * Default implementation returns an empty stream indicating that a TestApi does not depend on any * other TestApi's. * * @return */ default Stream> getTestApiDependencies() { return Stream.empty(); } interface TestContext { /** * Registers a given Service in the associated TestContext. The service will be registered in the * service registry associated with the given TestContext.

* * @param serviceBean * @param serviceImpl */ void registerService(Class serviceBean, T serviceImpl); /** * See {@link #registerService(Class, Object)} * @param serviceBean * @param qualifier * @param serviceImpl */ void registerService(Class serviceBean, String qualifier, T serviceImpl); /** * Each TestContext has an AstrixContext (which is managed by the associated AstrixRule). The AstrixContext * is shared between all TestApi instances. Beans might be pulled from the * AstrixContext using this method. */ T getBean(Class beanType); /** * see {@link #getBean(Class)} */ T getBean(Class beanType, String qualifier); /** * Returns a TestApi instance from the given TestContext. * * @param testApi * @return */ T getTestApi(Class testApi); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy