// Copyright 2019 Google LLC
//
// 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
//
//     https://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.google.sps;

import com.google.sps.data.ShoppingListTextEntry;
import java.util.List;

public class FakeTextDetectionAPIImpl implements TextDetectionAPI {
  private List<ShoppingListTextEntry> detectedData;
  private PhotoDetectionException photoDetectionException;

  /** Set detectedData to be returned. */
  public void setReturnValue(List<ShoppingListTextEntry> detectedData) {
    this.detectedData = detectedData;
  }

  /** Set exception to be thrown. */
  public void setException(PhotoDetectionException photoDetectionException) {
    this.photoDetectionException = photoDetectionException;
  }

  public List<ShoppingListTextEntry> detect(byte[] imageBytes) throws PhotoDetectionException {
    if (photoDetectionException != null) {
      throw this.photoDetectionException;
    }
    return this.detectedData;
  }
}

@@ -681,16 +681,278 @@
 .List;%0A%0A
+/**%0A  * This is a fake class used in the unit tests to avoid triggering cloudVisionAPI calls.%0A  * The test's setup should provide either of the two values%0A  * 1) Set the exception status%0A  * 2) Set the data value with expected response to be returned back.%0A  */%0A
 public c
@@ -1129,19 +1129,46 @@
 %0A%0A  /** 
-Set
+%0A   * Set expected response in
  detecte
@@ -1173,16 +1173,25 @@
 tedData 
+variable 
 to be re
@@ -1198,16 +1198,99 @@
 turned. 
+%0A   * Called from the test's setup, passing the expected response as parameter %0A   
 */%0A  pub
@@ -1406,16 +1406,22 @@
 %0A%0A  /** 
+%0A   * 
 Set exce
@@ -1440,16 +1440,113 @@
 thrown. 
+%0A   * Called from the test's setup, passing the expected photoDetectionException as parameter%0A   
 */%0A  pub

Update comments