/*
 * Copyright 2015-present Facebook, Inc.
 *
 *  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 com.facebook.buck.android;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import com.facebook.buck.testutil.integration.DebuggableTemporaryFolder;
import com.facebook.buck.testutil.integration.ProjectWorkspace;
import com.facebook.buck.testutil.integration.ProjectWorkspace.ProcessResult;
import com.facebook.buck.testutil.integration.TestDataHelper;
import com.facebook.buck.util.HumanReadableException;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import java.io.IOException;

public class AndroidBinaryFlavorsIntegrationTest {

  @Rule
  public DebuggableTemporaryFolder temporaryFolder = new DebuggableTemporaryFolder();

  private ProjectWorkspace workspace;

  @Before
  public void setUp() throws IOException {
    AssumeAndroidPlatform.assumeSdkIsAvailable();
    AssumeAndroidPlatform.assumeNdkIsAvailable();
    workspace = TestDataHelper.createProjectWorkspaceForScenario(
        this,
        "android_project",
        temporaryFolder);
    workspace.setUp();
  }

  @Test
  public void testPackageStringAssetsFlavorOutput() throws IOException {
    ProcessResult result = workspace.runBuckCommand(
        "targets",
        "--show-output",
        "//apps/sample:app_comp_str#package_string_assets");
    result.assertSuccess();
    assertEquals(
        "buck-out/bin/apps/sample/__strings_app_comp_str#package_string_assets__/string_assets.zip",
        result.getStdout().trim().split(" ")[1]);
  }

  @Test
  public void testPackageStringAssetsFlavorDoesNotExist() throws IOException {
    try {
      workspace.runBuckCommand(
          "targets",
          "--show-output",
          "//apps/sample:app#package_string_assets");
      fail("The targets command should have thrown an exception");
    } catch (HumanReadableException e) {
      assertTrue(e.getHumanReadableErrorMessage().contains("flavor does not exist"));
    }
  }
}

@@ -645,16 +645,61 @@
 droid;%0A%0A
+import static org.hamcrest.Matchers.equalTo;%0A
 import s
@@ -727,22 +727,20 @@
 t.assert
-Equals
+That
 ;%0Aimport
@@ -1245,16 +1245,44 @@
 ception;
+%0Aimport java.nio.file.Paths;
 %0A%0Apublic
@@ -2022,49 +2022,21 @@
     
-result.assertSuccess();%0A    assertEquals(
+String path =
 %0A   
@@ -2131,17 +2131,61 @@
 ets.zip%22
-,
+;%0A    result.assertSuccess();%0A    assertThat(
 %0A       
@@ -2224,16 +2224,61 @@
 (%22 %22)%5B1%5D
+,%0A        equalTo(Paths.get(path).toString())
 );%0A  %7D%0A%0A

Fix AndroidBinaryFlavorsIntegrationTest to pass on Windows