mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
do not create config.xml during unit test
This commit is contained in:
@@ -21,9 +21,10 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.api.v2.resources;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@@ -45,6 +46,7 @@ import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* RESTful Web Service Resource to manage the configuration.
|
||||
@@ -61,6 +63,8 @@ public class ConfigResource {
|
||||
private final ScmConfiguration configuration;
|
||||
private final NamespaceStrategyValidator namespaceStrategyValidator;
|
||||
|
||||
private Consumer<ScmConfiguration> store = (config) -> ScmConfigurationUtil.getInstance().store(config);
|
||||
|
||||
@Inject
|
||||
public ConfigResource(ConfigDtoToScmConfigurationMapper dtoToConfigMapper,
|
||||
ScmConfigurationToConfigDtoMapper configToDtoMapper,
|
||||
@@ -71,6 +75,11 @@ public class ConfigResource {
|
||||
this.namespaceStrategyValidator = namespaceStrategyValidator;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setStore(Consumer<ScmConfiguration> store) {
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the global scm config.
|
||||
*/
|
||||
@@ -137,7 +146,7 @@ public class ConfigResource {
|
||||
ScmConfiguration config = dtoToConfigMapper.map(configDto);
|
||||
synchronized (ScmConfiguration.class) {
|
||||
configuration.load(config);
|
||||
ScmConfigurationUtil.getInstance().store(configuration);
|
||||
store.accept(configuration);
|
||||
}
|
||||
|
||||
return Response.noContent().build();
|
||||
|
||||
Reference in New Issue
Block a user