// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java
// public static TestArtifactBuilder testArtifact() {
//     return new TestArtifactBuilder();
// }
// 
// Path: src/test/java/org/simplify4u/plugins/TestUtils.java
// public static KeysMapLocationConfig aKeysMapLocationConfig(String location) {
//     KeysMapLocationConfig config = new KeysMapLocationConfig();
//     config.set(location);
//     return config;
// }
// 
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyFingerprint.java
// @Value
// @RequiredArgsConstructor
// public class KeyFingerprint {
// 
//     byte[] fingerprint;
// 
//     /**
//      * Construct a key fingerprint from string representation.
//      * @param strFingerprint a key fingerprint as string
//      */
//     public KeyFingerprint(String strFingerprint) {
//         fingerprint = HexUtils.stringToFingerprint(strFingerprint);
//     }
// 
//     @JsonValue
//     public String toString() {
//         return HexUtils.fingerprintToString(fingerprint);
//     }
// }
// 
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java
// @Builder
// @Value
// public class KeyInfo {
// 
//     @NonNull
//     KeyFingerprint fingerprint;
// 
//     KeyFingerprint master;
// 
//     Collection<String> uids;
// 
//     int version;
//     int algorithm;
// 
//     int bits;
// 
//     Date date;
// }


import org.simplify4u.plugins.pgp.KeyInfo;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.simplify4u.plugins.TestArtifactBuilder.testArtifact;
import static org.simplify4u.plugins.TestUtils.aKeysMapLocationConfig;
import org.apache.maven.artifact.Artifact;
import org.codehaus.plexus.resource.ResourceManager;
import org.codehaus.plexus.resource.loader.ResourceNotFoundException;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.testng.MockitoTestNGListener;
import org.simplify4u.plugins.pgp.KeyFingerprint;
/*
 * Copyright 2021 Slawomir Jaranowski
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.simplify4u.plugins.keysmap;




@Listeners(MockitoTestNGListener.class)
public class KeysMapMultiTest {

    @Mock
    private ResourceManager resourceManager;

    @InjectMocks
    private KeysMap keysMap;

    @BeforeMethod
    public void setup() throws ResourceNotFoundException {
        doAnswer(invocation -> getClass().getResourceAsStream(invocation.getArgument(0)))
                .when(resourceManager).getResourceAsInputStream(anyString());
    }

    @Test
    public void loadMultipleKeysMapShouldContainsAllItems() throws ResourceNotFoundException, IOException {

        keysMap.load(aKeysMapLocationConfig("/keysMapMulti1.list"));
        keysMap.load(aKeysMapLocationConfig("/keysMapMulti2.list"));

        assertThat(keysMap.size()).isEqualTo(9);
    }

    @DataProvider
    public static Object[][] artifactWithKeyToTest() {
        return new Object[][]{
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java
// public static TestArtifactBuilder testArtifact() {
//     return new TestArtifactBuilder();
// }
// 
// Path: src/test/java/org/simplify4u/plugins/TestUtils.java
// public static KeysMapLocationConfig aKeysMapLocationConfig(String location) {
//     KeysMapLocationConfig config = new KeysMapLocationConfig();
//     config.set(location);
//     return config;
// }
// 
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyFingerprint.java
// @Value
// @RequiredArgsConstructor
// public class KeyFingerprint {
// 
//     byte[] fingerprint;
// 
//     /**
//      * Construct a key fingerprint from string representation.
//      * @param strFingerprint a key fingerprint as string
//      */
//     public KeyFingerprint(String strFingerprint) {
//         fingerprint = HexUtils.stringToFingerprint(strFingerprint);
//     }
// 
//     @JsonValue
//     public String toString() {
//         return HexUtils.fingerprintToString(fingerprint);
//     }
// }
// 
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java
// @Builder
// @Value
// public class KeyInfo {
// 
//     @NonNull
//     KeyFingerprint fingerprint;
// 
//     KeyFingerprint master;
// 
//     Collection<String> uids;
// 
//     int version;
//     int algorithm;
// 
//     int bits;
// 
//     Date date;
// }


// Path: src/test/java/org/simplify4u/plugins/keysmap/KeysMapMultiTest.java
import org.simplify4u.plugins.pgp.KeyInfo;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.simplify4u.plugins.TestArtifactBuilder.testArtifact;
import static org.simplify4u.plugins.TestUtils.aKeysMapLocationConfig;
import org.apache.maven.artifact.Artifact;
import org.codehaus.plexus.resource.ResourceManager;
import org.codehaus.plexus.resource.loader.ResourceNotFoundException;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.testng.MockitoTestNGListener;
import org.simplify4u.plugins.pgp.KeyFingerprint;

/*
 * Copyright 2021 Slawomir Jaranowski
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.simplify4u.plugins.keysmap;




@Listeners(MockitoTestNGListener.class)
public class KeysMapMultiTest {

    @Mock
    private ResourceManager resourceManager;

    @InjectMocks
    private KeysMap keysMap;

    @BeforeMethod
    public void setup() throws ResourceNotFoundException {
        doAnswer(invocation -> getClass().getResourceAsStream(invocation.getArgument(0)))
                .when(resourceManager).getResourceAsInputStream(anyString());
    }

    @Test
    public void loadMultipleKeysMapShouldContainsAllItems() throws ResourceNotFoundException, IOException {

        keysMap.load(aKeysMapLocationConfig("/keysMapMulti1.list"));
        keysMap.load(aKeysMapLocationConfig("/keysMapMulti2.list"));

        assertThat(keysMap.size()).isEqualTo(9);
    }

    @DataProvider
    public static Object[][] artifactWithKeyToTest() {
        return new Object[][]{
                {testArtifact().build(),