// Path: phantomjs-maven-core/src/main/java/com/github/klieber/phantomjs/sys/SystemProperties.java
// @Named
// public class SystemProperties {
// 
//   private static final String OS_NAME = "os.name";
//   private static final String OS_VERSION = "os.version";
//   private static final String OS_ARCH = "os.arch";
//   private static final String ENV_PATH = "PATH";
// 
//   public String getOsName() {
//     return getSystemProperty(OS_NAME);
//   }
// 
//   public String getOsVersion() {
//     return getSystemProperty(OS_VERSION);
//   }
// 
//   public String getOsArch() {
//     return getSystemProperty(OS_ARCH);
//   }
// 
//   public List<String> getPath() {
//     String systemPath = System.getenv(ENV_PATH);
//     return systemPath != null ? Arrays.asList(systemPath.split(File.pathSeparator)) : Collections.<String>emptyList();
//   }
// 
//   private String getSystemProperty(String name) {
//     String property = System.getProperty(name);
//     return property != null ? property.toLowerCase() : null;
//   }
// }
// 
// Path: phantomjs-maven-core/src/test/java/com/github/klieber/phantomjs/test/MockPhantomJsBinary.java
// public class MockPhantomJsBinary extends ExternalResource {
// 
//   private static final String DEFAULT_TARGET_FOLDER = System.getProperty("user.dir")+"/target/";
//   private static final String PHANTOMJS_FILE_NAME = "phantomjs";
// 
//   private final File phantomJsBinary;
//   private final String version;
// 
//   public MockPhantomJsBinary(String version) {
//     this(DEFAULT_TARGET_FOLDER, version);
//   }
// 
//   public MockPhantomJsBinary(String targetFolder, String version) {
//     this(new File(targetFolder, PHANTOMJS_FILE_NAME), version);
//   }
// 
//   public MockPhantomJsBinary(File phantomJsBinary, String version) {
//     this.phantomJsBinary = phantomJsBinary;
//     this.version = version;
//   }
// 
//   @Override
//   protected void before() throws Throwable {
//     PrintWriter writer = new PrintWriter(this.phantomJsBinary);
//     writer.println("#!/bin/sh");
//     writer.println("echo "+this.version);
//     writer.close();
//     this.phantomJsBinary.setExecutable(true);
//   }
// 
//   @Override
//   protected void after() {
//     if (this.phantomJsBinary.exists()) {
//       this.phantomJsBinary.delete();
//     }
//   }
// 
//   public File get() {
//     return this.phantomJsBinary;
//   }
// 
// }


import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;
import static org.mockito.Mockito.when;
import com.github.klieber.phantomjs.sys.SystemProperties;
import com.github.klieber.phantomjs.test.MockPhantomJsBinary;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
/*-
 * #%L
 * PhantomJS Maven Core
 * %%
 * Copyright (C) 2013 - 2017 Kyle Lieber
 * %%
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 * #L%
 */
package com.github.klieber.phantomjs.resolve;




@RunWith(MockitoJUnitRunner.class)
public class PathResolverTest {

  private static final String VERSION = "1.9.0";

  @ClassRule
  public static final MockPhantomJsBinary phantomJsBinary = new MockPhantomJsBinary(VERSION);

  @Mock
  private SystemProperties systemProperties;

  @Before
  public void before() {
    assumeUnixOs();
  }

  @Test
  public void testShouldNotResolve() {
    when(systemProperties.getPath()).thenReturn(Collections.singletonList("/tmp"));
    assertThat(getResolver(VERSION).resolve()).isNull();
  }

// Path: phantomjs-maven-core/src/main/java/com/github/klieber/phantomjs/sys/SystemProperties.java
// @Named
// public class SystemProperties {
// 
//   private static final String OS_NAME = "os.name";
//   private static final String OS_VERSION = "os.version";
//   private static final String OS_ARCH = "os.arch";
//   private static final String ENV_PATH = "PATH";
// 
//   public String getOsName() {
//     return getSystemProperty(OS_NAME);
//   }
// 
//   public String getOsVersion() {
//     return getSystemProperty(OS_VERSION);
//   }
// 
//   public String getOsArch() {
//     return getSystemProperty(OS_ARCH);
//   }
// 
//   public List<String> getPath() {
//     String systemPath = System.getenv(ENV_PATH);
//     return systemPath != null ? Arrays.asList(systemPath.split(File.pathSeparator)) : Collections.<String>emptyList();
//   }
// 
//   private String getSystemProperty(String name) {
//     String property = System.getProperty(name);
//     return property != null ? property.toLowerCase() : null;
//   }
// }
// 
// Path: phantomjs-maven-core/src/test/java/com/github/klieber/phantomjs/test/MockPhantomJsBinary.java
// public class MockPhantomJsBinary extends ExternalResource {
// 
//   private static final String DEFAULT_TARGET_FOLDER = System.getProperty("user.dir")+"/target/";
//   private static final String PHANTOMJS_FILE_NAME = "phantomjs";
// 
//   private final File phantomJsBinary;
//   private final String version;
// 
//   public MockPhantomJsBinary(String version) {
//     this(DEFAULT_TARGET_FOLDER, version);
//   }
// 
//   public MockPhantomJsBinary(String targetFolder, String version) {
//     this(new File(targetFolder, PHANTOMJS_FILE_NAME), version);
//   }
// 
//   public MockPhantomJsBinary(File phantomJsBinary, String version) {
//     this.phantomJsBinary = phantomJsBinary;
//     this.version = version;
//   }
// 
//   @Override
//   protected void before() throws Throwable {
//     PrintWriter writer = new PrintWriter(this.phantomJsBinary);
//     writer.println("#!/bin/sh");
//     writer.println("echo "+this.version);
//     writer.close();
//     this.phantomJsBinary.setExecutable(true);
//   }
// 
//   @Override
//   protected void after() {
//     if (this.phantomJsBinary.exists()) {
//       this.phantomJsBinary.delete();
//     }
//   }
// 
//   public File get() {
//     return this.phantomJsBinary;
//   }
// 
// }


// Path: phantomjs-maven-core/src/test/java/com/github/klieber/phantomjs/resolve/PathResolverTest.java
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;
import static org.mockito.Mockito.when;
import com.github.klieber.phantomjs.sys.SystemProperties;
import com.github.klieber.phantomjs.test.MockPhantomJsBinary;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;

/*-
 * #%L
 * PhantomJS Maven Core
 * %%
 * Copyright (C) 2013 - 2017 Kyle Lieber
 * %%
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 * #L%
 */
package com.github.klieber.phantomjs.resolve;




@RunWith(MockitoJUnitRunner.class)
public class PathResolverTest {

  private static final String VERSION = "1.9.0";

  @ClassRule
  public static final MockPhantomJsBinary phantomJsBinary = new MockPhantomJsBinary(VERSION);

  @Mock
  private SystemProperties systemProperties;

  @Before
  public void before() {
    assumeUnixOs();
  }

  @Test
  public void testShouldNotResolve() {
    when(systemProperties.getPath()).thenReturn(Collections.singletonList("/tmp"));
    assertThat(getResolver(VERSION).resolve()).isNull();
  }

  @Test