001package org.apache.maven.scm.provider.accurev.cli;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import static org.hamcrest.Matchers.hasItem;
023import static org.hamcrest.Matchers.is;
024import static org.junit.Assert.assertThat;
025
026import java.io.File;
027import java.util.ArrayList;
028import java.util.Collection;
029
030import org.junit.Test;
031
032public class StatBackingConsumerTest
033{
034
035    @Test
036    public void testConsumeLine()
037    {
038        Collection<File> nonMemberElements = new ArrayList<File>();
039        Collection<File> memberElements = new ArrayList<File>();
040
041        String line1 = "./hello.world  maventst/1 (2/1) (member)";
042        String line2 = "./tcktests/readme.txt  (no such elem)";
043        String line3 = "./src      maventst/1 (2/1) (member)";
044        String line4 = "./target   (no such elem)";
045
046        StatBackingConsumer consumer = new StatBackingConsumer( memberElements, nonMemberElements );
047
048        consumer.consumeLine( line1 );
049        consumer.consumeLine( line2 );
050        consumer.consumeLine( line3 );
051        consumer.consumeLine( line4 );
052
053        assertThat( memberElements.size(), is( 2 ) );
054        assertThat( nonMemberElements.size(), is( 2 ) );
055        assertThat( memberElements, hasItem( new File( "./hello.world" ) ) );
056        assertThat( memberElements, hasItem( new File( "./src" ) ) );
057        assertThat( nonMemberElements, hasItem( new File( "./tcktests/readme.txt" ) ) );
058        assertThat( nonMemberElements, hasItem( new File( "./target" ) ) );
059
060    }
061}