// 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 KeyInfo aKeyInfo(String fingerprint) {
//     return KeyInfo.builder().fingerprint(new KeyFingerprint(fingerprint)).build();
// }
// 
// Path: src/test/java/org/simplify4u/plugins/TestUtils.java
// public static KeysMapLocationConfig aKeysMapLocationConfig(String location) {
//     KeysMapLocationConfig config = new KeysMapLocationConfig();
//     config.set(location);
//     return config;
// }


import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.simplify4u.plugins.TestArtifactBuilder.testArtifact;
import static org.simplify4u.plugins.TestUtils.aKeyInfo;
import static org.simplify4u.plugins.TestUtils.aKeysMapLocationConfig;
import org.codehaus.plexus.resource.ResourceManager;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.testng.MockitoTestNGListener;
import org.slf4j.Logger;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
/*
 * Copyright 2020 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;



/**
 * @author Slawomir Jaranowski.
 */
@Listeners(MockitoTestNGListener.class)
public class KeysMapTest {

    @Mock
    private ResourceManager resourceManager;

    @Mock(name = "org.simplify4u.plugins.keysmap.KeysMap")
    private Logger loggerKeysMap;

    @Mock(name = "org.simplify4u.plugins.keysmap.KeyItems")
    private Logger loggerKeyItems;

    @InjectMocks
    private KeysMap keysMap;

    @Test
    public void isComponentSet() {
        assertThat(keysMap).isNotNull();
    }

    @Test
    public void nullLocationTest() throws Exception {

        assertThatThrownBy(() -> keysMap.load(null))
                .isExactlyInstanceOf(NullPointerException.class);

        verifyNoInteractions(resourceManager);
// 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 KeyInfo aKeyInfo(String fingerprint) {
//     return KeyInfo.builder().fingerprint(new KeyFingerprint(fingerprint)).build();
// }
// 
// 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/test/java/org/simplify4u/plugins/keysmap/KeysMapTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.simplify4u.plugins.TestArtifactBuilder.testArtifact;
import static org.simplify4u.plugins.TestUtils.aKeyInfo;
import static org.simplify4u.plugins.TestUtils.aKeysMapLocationConfig;
import org.codehaus.plexus.resource.ResourceManager;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.testng.MockitoTestNGListener;
import org.slf4j.Logger;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;

/*
 * Copyright 2020 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;



/**
 * @author Slawomir Jaranowski.
 */
@Listeners(MockitoTestNGListener.class)
public class KeysMapTest {

    @Mock
    private ResourceManager resourceManager;

    @Mock(name = "org.simplify4u.plugins.keysmap.KeysMap")
    private Logger loggerKeysMap;

    @Mock(name = "org.simplify4u.plugins.keysmap.KeyItems")
    private Logger loggerKeyItems;

    @InjectMocks
    private KeysMap keysMap;

    @Test
    public void isComponentSet() {
        assertThat(keysMap).isNotNull();
    }

    @Test
    public void nullLocationTest() throws Exception {

        assertThatThrownBy(() -> keysMap.load(null))
                .isExactlyInstanceOf(NullPointerException.class);

        verifyNoInteractions(resourceManager);
        assertThat(keysMap.isValidKey(testArtifact().build(), null)).isTrue();