/*
Copyright 2014 Google Inc. All rights reserved.

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.google.cloud.genomics.api.client.commands;

import com.google.api.services.genomics.Genomics;
import com.google.api.services.genomics.model.Job;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.io.IOException;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;

@RunWith(JUnit4.class)
public class BaseCommandTest {
  @Test
  public void testIsJobFinished() throws Exception {
    BaseCommand command = new BaseCommand() {
      @Override
      public void handleRequest(Genomics genomics) throws IOException {}
    };

    Job job = new Job();
    assertFalse(command.isJobFinished(job));

    job.setStatus("running");
    assertFalse(command.isJobFinished(job));

    job.setStatus("success");
    assertTrue(command.isJobFinished(job));

    job.setStatus("failure");
    assertTrue(command.isJobFinished(job));
  }
}

@@ -643,45 +643,264 @@
 com.
-google.api.services.genomics.Genomics
+beust.jcommander.internal.Lists;%0Aimport com.google.api.client.util.store.MemoryDataStoreFactory;%0Aimport com.google.api.services.genomics.Genomics;%0Aimport com.google.api.services.genomics.GenomicsScopes;%0Aimport com.google.api.services.genomics.model.Dataset
 ;%0Aim
@@ -948,16 +948,41 @@
 el.Job;%0A
+import org.junit.Before;%0A
 import o
@@ -1090,16 +1090,38 @@
 ception;
+%0Aimport java.util.Map;
 %0A%0Aimport
@@ -1212,16 +1212,61 @@
 ertTrue;
+%0Aimport static org.junit.Assert.assertEquals;
 %0A%0A@RunWi
@@ -1319,82 +1319,75 @@
 %7B%0A  
-@Test%0A  public void testIsJobFinished() throws Exception %7B%0A    BaseCommand
+private BaseCommand command;%0A%0A  @Before%0A  public void setup() %7B%0A   
  com
@@ -1509,16 +1509,81 @@
 %0A    %7D;%0A
+  %7D%0A%0A  @Test%0A  public void testIsJobFinished() throws Exception %7B
 %0A    Job
@@ -1874,11 +1874,1080 @@
 b));%0A  %7D
+%0A%0A  @Test%0A  public void testScopes() throws Exception %7B%0A    assertEquals(Lists.newArrayList(GenomicsScopes.GENOMICS), command.getScopes());%0A  %7D%0A%0A  @Test%0A  public void testDatasetHistory() throws Exception %7B%0A    MemoryDataStoreFactory factory = new MemoryDataStoreFactory();%0A    command.setDataStoreFactory(factory);%0A%0A    assertTrue(command.getPreviousDatasets().isEmpty());%0A%0A    Dataset dataset = new Dataset();%0A    dataset.setId(%22d1%22);%0A    dataset.setName(%22name1%22);%0A    command.addDatasetToHistory(dataset);%0A%0A    Map%3CString,String%3E datasets = command.getPreviousDatasets();%0A    assertEquals(1, datasets.size());%0A    assertEquals(%22name1%22, datasets.get(%22d1%22));%0A  %7D%0A%0A  @Test%0A  public void testJobHistory() throws Exception %7B%0A    MemoryDataStoreFactory factory = new MemoryDataStoreFactory();%0A    command.setDataStoreFactory(factory);%0A%0A    assertTrue(command.getLaunchedJobs().isEmpty());%0A%0A    command.addJobToHistory(%22j1%22, %22name1%22);%0A%0A    Map%3CString,String%3E jobs = command.getLaunchedJobs();%0A    assertEquals(1, jobs.size());%0A    assertEquals(%22name1%22, jobs.get(%22j1%22));%0A  %7D
 %0A%7D%0A

Add more tests!