Debian Codegraph @

maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/ScmFileMatcher.java

raw symbols SCIP
1 package org.apache.maven.scm;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the
6 * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a
7 * copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
12 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
13 * governing permissions and limitations under the License.
14 */
15
16 import java.io.File;
17 import java.util.List;
18
19 import org.hamcrest.Description;
20 import org.hamcrest.Matcher;
21 import org.hamcrest.Matchers;
22 import org.hamcrest.TypeSafeMatcher;
23
24 public class ScmFileMatcher
25 extends TypeSafeMatcher<ScmFile>
26 {
27
28 public static Matcher<ScmFile> scmFile( String fileName, ScmFileStatus status )
29 {
30 return new ScmFileMatcher( fileName, status );
31 }
32
33 @SuppressWarnings( "unchecked" )
34 public static void assertHasScmFile( List<?> actualFiles, String fileName, ScmFileStatus status )
35 {
36 org.hamcrest.MatcherAssert.assertThat( (List<ScmFile>) actualFiles,
37 Matchers.<ScmFile>hasItem( scmFile( fileName, status ) ) );
38 }
39
40 private ScmFileStatus status;
41
42 private String filePath;
43
44 public ScmFileMatcher( String filePath, ScmFileStatus status )
45 {
46 // Convert to OS specific path...
47 this.filePath = new File( filePath ).getPath();
48 this.status = status;
49 }
50
51 public void describeTo( Description desc )
52 {
53 desc.appendValue( "ScmFile [" );
54 desc.appendValue( filePath );
55 desc.appendText( "," );
56 desc.appendValue( status );
57 desc.appendValue( "]" );
58 }
59
60 @Override
61 public boolean matchesSafely( ScmFile scmFile )
62 {
63 return scmFile.getPath().equals( filePath ) && scmFile.getStatus().equals( status );
64 }
65
66 }