package com.google.job.data;

import com.google.cloud.firestore.Firestore;
import com.google.cloud.firestore.QueryDocumentSnapshot;
import com.google.firestore.FireStoreUtils;
import org.junit.Assert;
import org.junit.Test;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutionException;

class JobsDatabaseTest {

    private static final String JOB_COLLECTION = "Jobs";

    Firestore firestore = FireStoreUtils.getFireStore();
    JobsDatabase jobsDatabase = new JobsDatabase(firestore);

    JobsDatabaseTest() throws IOException {
    }

    @Test
    void addJob_NormalInput_success() throws ExecutionException, InterruptedException {
        String expectedJobName = "Noogler";
        Job job = new Job(expectedJobName);
        jobsDatabase.addJob(job);

        List<QueryDocumentSnapshot> documentSnapshots = firestore.collection(JOB_COLLECTION).get().get().getDocuments();
        Job actualJob = documentSnapshots.get(0).toObject(Job.class);

        String actualJobName = actualJob.getJobName();

        Assert.assertEquals(expectedJobName, actualJobName);
    }

    @Test
    void editJob_NormalInput_success() throws ExecutionException, InterruptedException {
        String expectedJobName = "Googler";
        Job job = new Job(expectedJobName);

        List<QueryDocumentSnapshot> documentSnapshots = firestore.collection(JOB_COLLECTION).get().get().getDocuments();
        String jobId = documentSnapshots.get(0).getId();
        System.out.println(jobId);

        jobsDatabase.editJob(jobId, job);

        documentSnapshots = firestore.collection(JOB_COLLECTION).get().get().getDocuments();
        Job actualJob = documentSnapshots.get(0).toObject(Job.class);

        String actualJobName = actualJob.getJobName();

        Assert.assertEquals(expectedJobName, actualJobName);
    }

    @Test
    void fetchJob_NormalInput_success() throws ExecutionException, InterruptedException {
        List<QueryDocumentSnapshot> documentSnapshots = firestore.collection(JOB_COLLECTION).get().get().getDocuments();
        String jobId = documentSnapshots.get(0).getId();

        Job job = documentSnapshots.get(0).toObject(Job.class);

        String actualJobName = job.getJobName();
        String expectedJobName = "Googler";

        Assert.assertEquals(expectedJobName, actualJobName);
    }
}
@@ -318,16 +318,29 @@
 ption;%0A%0A
+public final 
 class Jo
@@ -429,16 +429,118 @@
 restore 
+firestore;%0A    JobsDatabase jobsDatabase;%0A%0A    public JobsDatabaseTest() throws IOException %7B%0A        
 firestor
@@ -574,36 +574,27 @@
 tore();%0A    
-JobsDatabase
+   
  jobsDatabas
@@ -629,53 +629,8 @@
 re);
-%0A%0A    JobsDatabaseTest() throws IOException %7B
 %0A   
@@ -643,24 +643,31 @@
   @Test%0A    
+public 
 void addJob_
@@ -1187,24 +1187,31 @@
   @Test%0A    
+public 
 void editJob
@@ -1553,43 +1553,8 @@
 d();
-%0A        System.out.println(jobId);
 %0A%0A  
@@ -1896,16 +1896,23 @@
 est%0A    
+public 
 void fet

Make all methods in test public