3 * Copyright (C) 2009-2019 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.ce.task.projectanalysis.filemove;
22 import com.google.common.base.Optional;
23 import java.util.HashSet;
25 import javax.annotation.CheckForNull;
26 import org.junit.rules.ExternalResource;
27 import org.sonar.ce.task.projectanalysis.component.Component;
29 public class MutableMovedFilesRepositoryRule extends ExternalResource implements MutableMovedFilesRepository {
31 private MutableMovedFilesRepository delegate;
32 private final Set<Component> componentsWithOriginal = new HashSet<>();
35 protected void before() {
36 this.delegate = new MutableMovedFilesRepositoryImpl();
37 this.componentsWithOriginal.clear();
41 protected void after() {
43 this.componentsWithOriginal.clear();
47 public void setOriginalFile(Component file, OriginalFile originalFile) {
48 this.delegate.setOriginalFile(file, originalFile);
49 this.componentsWithOriginal.add(file);
53 public Optional<OriginalFile> getOriginalFile(Component file) {
54 return this.delegate.getOriginalFile(file);
57 public Set<Component> getComponentsWithOriginal() {
58 return componentsWithOriginal;