View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.archiver;
20  
21  import java.util.Map;
22  
23  import org.junit.jupiter.api.BeforeEach;
24  import org.junit.jupiter.api.Test;
25  
26  import static org.assertj.core.api.Assertions.assertThat;
27  import static org.assertj.core.api.Assertions.entry;
28  
29  /**
30   * @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmarbaise@apache.org</a>.
31   */
32  class MavenArchiveConfigurationTest {
33  
34      private MavenArchiveConfiguration archive;
35  
36      @BeforeEach
37      void before() {
38          archive = new MavenArchiveConfiguration();
39          archive.setManifest(new ManifestConfiguration());
40          archive.setForced(false);
41          archive.setCompress(false);
42      }
43  
44      @Test
45      void addingSingleEntryShouldBeReturned() {
46          archive.addManifestEntry("key1", "value1");
47          Map<String, String> manifestEntries = archive.getManifestEntries();
48          assertThat(manifestEntries).containsExactly(entry("key1", "value1"));
49      }
50  
51      @Test
52      void addingTwoEntriesShouldBeReturnedInInsertOrder() {
53          archive.addManifestEntry("key1", "value1");
54          archive.addManifestEntry("key2", "value2");
55          Map<String, String> manifestEntries = archive.getManifestEntries();
56          assertThat(manifestEntries).containsExactly(entry("key1", "value1"), entry("key2", "value2"));
57      }
58  
59      @Test
60      void addingThreeEntriesShouldBeReturnedInInsertOrder() {
61          archive.addManifestEntry("key1", "value1");
62          archive.addManifestEntry("key2", "value2");
63          archive.addManifestEntry("key3", "value3");
64          Map<String, String> manifestEntries = archive.getManifestEntries();
65          assertThat(manifestEntries)
66                  .containsExactly(entry("key1", "value1"), entry("key2", "value2"), entry("key3", "value3"));
67      }
68  }