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          archive.setIndex(false);
43      }
44  
45      @Test
46      void addingSingleEntryShouldBeReturned() {
47          archive.addManifestEntry("key1", "value1");
48          Map<String, String> manifestEntries = archive.getManifestEntries();
49          assertThat(manifestEntries).containsExactly(entry("key1", "value1"));
50      }
51  
52      @Test
53      void addingTwoEntriesShouldBeReturnedInInsertOrder() {
54          archive.addManifestEntry("key1", "value1");
55          archive.addManifestEntry("key2", "value2");
56          Map<String, String> manifestEntries = archive.getManifestEntries();
57          assertThat(manifestEntries).containsExactly(entry("key1", "value1"), entry("key2", "value2"));
58      }
59  
60      @Test
61      void addingThreeEntriesShouldBeReturnedInInsertOrder() {
62          archive.addManifestEntry("key1", "value1");
63          archive.addManifestEntry("key2", "value2");
64          archive.addManifestEntry("key3", "value3");
65          Map<String, String> manifestEntries = archive.getManifestEntries();
66          assertThat(manifestEntries)
67                  .containsExactly(entry("key1", "value1"), entry("key2", "value2"), entry("key3", "value3"));
68      }
69  }