View Javadoc
1   /*
2    * Copyright The Plexus developers.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.codehaus.plexus.archiver.util;
17  
18  import java.util.stream.Stream;
19  
20  import org.junit.jupiter.params.ParameterizedTest;
21  import org.junit.jupiter.params.provider.Arguments;
22  import org.junit.jupiter.params.provider.MethodSource;
23  
24  import static org.assertj.core.api.Assertions.assertThat;
25  
26  class ResourceUtilsTest {
27  
28      public static Stream<Arguments> testIsUpToDate() {
29          return Stream.of(
30                  Arguments.of(0, 0, false), // dest and src 0
31                  Arguments.of(100, 0, false), // dest 0
32                  Arguments.of(0, 100, false), // src 0
33                  Arguments.of(100, 200, true),
34                  Arguments.of(200, 100, false),
35                  Arguments.of(100, 100, true));
36      }
37  
38      @ParameterizedTest
39      @MethodSource
40      void testIsUpToDate(long source, long destination, boolean expected) {
41          assertThat(ResourceUtils.isUptodate(source, destination)).isEqualTo(expected);
42      }
43  }