package com.google.sps.tool;

import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

import java.util.List;
import java.util.ArrayList;
import com.google.sps.data.Card;
import com.google.sps.data.Folder;

public class EntityTestingTool {

  public static boolean checkForNoNullValues(Entity card) {
    return (card.getProperty("blobKey") != null  &&
      card.getProperty("labels") != null &&
      card.getProperty("textTranslated") != null &&
      card.getProperty("textNotTranslated") != null &&
      card.getProperty("fromLang") != null &&
      card.getProperty("toLang") != null &&
      card.getProperty("cardKey") != null);
  }

  public static Folder populateDatastoreWithAFolder(Folder folder, DatastoreService datastore, String userKey) {
    
    Entity folderEntity = folder.createEntity(KeyFactory.stringToKey(userKey));

    // Update entity in datastore 
    datastore.put(folderEntity);

    Folder folderObject = new Folder(folderEntity);
    folderObject.setFolderKey(KeyFactory.keyToString(folderEntity.getKey()));
    
    return folderObject;
  }
  
  /*
  public static List<Card> populateDatastoreWithCards(Card cardA, Card cardB, DatastoreService datastore, String folderKey) {
    
    Entity cardEntityA = cardA.createEntity(KeyFactory.stringToKey(folderKey));
    Entity cardEntityB = cardB.createEntity(KeyFactory.stringToKey(folderKey));

    // Update entity in datastore 
    datastore.put(cardEntityA);
    datastore.put(cardEntityB);

    List<Card> cards = new ArrayList<>();
    cards.add(new Card(cardEntityA));
    cards.add(new Card(cardEntityB));

    return cards;
  }
  */

    
}
@@ -885,36 +885,30 @@
 der 
-populateDatastoreWithAFolder
+storeFolderInDatastore
 (Fol
@@ -973,74 +973,24 @@
     
-%0A    Entity folderEntity = folder.createEntity(KeyFactory.stringTo
+folder.setParent
 Key(
@@ -1001,794 +1001,190 @@
 Key)
-);%0A
+;
 %0A    
-// Update entity in datastore %0A    datastore.put(folderEntity);%0A%0A    Folder folderObject = new Folder(folder
+Entity folderEntity = folder.create
 Entity
+(
 );%0A    
-folderObject.setFolderKey(KeyFactory.keyToString(folderEntity.getKey()));%0A    %0A    return folderObject;%0A  %7D%0A  %0A  /*%0A  public static List%3CCard%3E populateDatastoreWithCards(Card cardA, Card cardB, DatastoreService datastore, String folderKey) %7B%0A    %0A    Entity cardEntityA = cardA.createEntity(KeyFactory.stringToKey(folderKey));%0A    Entity cardEntityB = cardB.createEntity(KeyFactory.stringToKey(folderKey));%0A%0A    // Update entity in datastore %0A    datastore.put(cardEntityA);%0A    datastore.put(cardEntityB);%0A%0A    List%3CCard%3E cards = new ArrayList%3C%3E();%0A    cards.add(new Card(cardEntityA));%0A    cards.add(new Card(cardEntityB));%0A%0A    return cards;%0A  %7D%0A  */%0A%0A    
+datastore.put(folderEntity);%0A%0A    folder.setFolderKey(KeyFactory.keyToString(folderEntity.getKey()));%0A    %0A    return folder;%0A  %7D
 %0A%7D

Delete unnecessary function