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