View Javadoc
1   package org.apache.maven.scm.provider.accurev;
2   
3   import java.util.Objects;
4   
5   /*
6    * Licensed to the Apache Software Foundation (ASF) under one
7    * or more contributor license agreements.  See the NOTICE file
8    * distributed with this work for additional information
9    * regarding copyright ownership.  The ASF licenses this file
10   * to you under the Apache License, Version 2.0 (the
11   * "License"); you may not use this file except in compliance
12   * with the License.  You may obtain a copy of the License at
13   *
14   *    http://www.apache.org/licenses/LICENSE-2.0
15   *
16   * Unless required by applicable law or agreed to in writing,
17   * software distributed under the License is distributed on an
18   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19   * KIND, either express or implied.  See the License for the
20   * specific language governing permissions and limitations
21   * under the License.
22   */
23  
24  import org.apache.maven.scm.provider.ScmProviderRepository;
25  import org.hamcrest.Description;
26  import org.hamcrest.Matcher;
27  import org.hamcrest.TypeSafeMatcher;
28  
29  public class AccuRevScmProviderRepositoryMatcher
30      extends TypeSafeMatcher<ScmProviderRepository>
31  {
32  
33      public static Matcher<ScmProviderRepository> isRepo( String user, String pass, String host, int port,
34                                                           String stream, String projectPath )
35  
36      {
37          return new AccuRevScmProviderRepositoryMatcher( user, pass, host, port, stream, projectPath );
38      }
39  
40      private String user;
41  
42      private String pass;
43  
44      private String host;
45  
46      private String projectPath;
47  
48      private String stream;
49  
50      private int port;
51  
52      public AccuRevScmProviderRepositoryMatcher( String user, String pass, String host, int port, String stream,
53                                                  String projectPath )
54      {
55          this.user = user;
56          this.pass = pass;
57          this.host = host;
58          this.port = port;
59          this.stream = stream;
60          this.projectPath = projectPath;
61  
62      }
63  
64      public void describeTo( Description desc )
65      {
66          desc.appendText( "an AccuRev repo with" );
67          desc.appendText( " user=" );
68          desc.appendValue( user );
69          desc.appendText( " pass=" );
70          desc.appendValue( pass );
71          desc.appendText( " host=" );
72          desc.appendValue( host );
73          desc.appendText( " port=" );
74          desc.appendValue( port );
75          desc.appendText( " stream=" );
76          desc.appendValue( stream );
77          desc.appendText( " projectPath=" );
78          desc.appendValue( projectPath );
79  
80      }
81  
82      @Override
83      public boolean matchesSafely( ScmProviderRepository repo )
84      {
85          if ( !( repo instanceof AccuRevScmProviderRepository ) )
86          {
87              return false;
88          }
89          AccuRevScmProviderRepository accuRevRepo = (AccuRevScmProviderRepository) repo;
90          return Objects.equals( user, accuRevRepo.getUser() )
91              && Objects.equals( pass, accuRevRepo.getPassword() )
92              && Objects.equals( host, accuRevRepo.getHost() ) && port == accuRevRepo.getPort()
93              && Objects.equals( stream, accuRevRepo.getStreamName() )
94              && Objects.equals( projectPath, accuRevRepo.getProjectPath() );
95  
96      }
97  }