// Path: src/main/java/shopJava/model/Order.java
// public class Order {
// 
//     private static final String ID = "_id";
//     private static final String USERNAME = "first";
//     private static final String AMOUNT = "amount";
// 
//     public final int id;
//     public final String username;
//     public final int amount;
// 
//     public Order(final int id, final String username, final int amount) {
//         this.id = id;
//         this.username = username;
//         this.amount = amount;
//     }
// 
//     public Order(final Document doc) {
//         this(doc.getInteger(ID), doc.getString(USERNAME), doc.getInteger(AMOUNT));
//     }
// 
//     @Override
//     public String toString() {
//         return "Order{" +
//                 ID + "=" + id +
//                 ", " + USERNAME + "='" + username + '\'' +
//                 ", " + AMOUNT + "=" + (amount/100.0) +
//                 '}';
//     }
// 
//     public void print() {
//         System.out.print(this);
//     }
// 
//     public void println() {
//         System.out.println(this);
//     }
// 
//     public Document toDocument() {
//         return new Document(ID, id).append(USERNAME, username).append(AMOUNT, amount);
//     }
// }
// 
// Path: src/main/java/shopJava/model/User.java
// public class User {
// 
//     private static final String ID = "_id";
//     private static final String NAME = "name";
//     private static final String PASSWORD = "password";
// 
//     public final String name;
//     public final String password;
// 
//     public User(final String name, final String password) {
//         this.name = name;
//         this.password = password;
//     }
// 
//     public User(Document doc) {
//         this(doc.getString(ID), doc.getString(PASSWORD));
//     }
// 
//     @Override
//     public String toString() {
//         return "User{" +
//                 NAME + "='" + name + '\'' +
//                 ", " + PASSWORD + "='" + password + '\'' +
//                 '}';
//     }
// 
//     public void print() {
//         System.out.print(this);
//     }
// 
//     public void println() {
//         System.out.println(this);
//     }
// 
//     public Document toDocument() {
//         return new Document(ID, name).append(PASSWORD, password);
//     }
// }
// 
// Path: src/main/java/shopJava/util/Constants.java
// public interface Constants {
// 
//     int MAX_ORDERS_PER_USER = 10;
// 
//     String MONGODB_URI = "mongodb://localhost:27017";
//     String SHOP_DB_NAME = "shop";
//     String USERS_COLLECTION_NAME = "users";
//     String ORDERS_COLLECTION_NAME = "orders";
// 
//     String HOMER = "homer";
//     String MARGE = "marge";
//     String BART = "bart";
//     String LISA = "lisa";
//     String MAGGIE = "maggie";
// 
//     String[] SIMPSONS = {HOMER, MARGE, BART, LISA, MAGGIE};
// }


import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import shopJava.model.Order;
import shopJava.model.User;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import static com.mongodb.client.model.Filters.eq;
import static java.util.stream.Collectors.toList;
import static shopJava.util.Constants.*;
    }
}

public class InsertUsersOrders {

    public static void main(String[] args) {
        new InsertUsersOrders();
    }

    private final Random random = new Random();

    private final UserDAO userDAO;
    private final OrderDAO orderDAO;

    public InsertUsersOrders() {

        final MongoClient client = new MongoClient(new MongoClientURI(MONGODB_URI));
        final  MongoDatabase db = client.getDatabase(SHOP_DB_NAME);

        final MongoCollection<Document> usersCollection = db.getCollection(USERS_COLLECTION_NAME);
        usersCollection.drop();
        userDAO = new UserDAO(usersCollection);

        final MongoCollection<Document> ordersCollection = db.getCollection(ORDERS_COLLECTION_NAME);
        ordersCollection.drop();
        orderDAO = new OrderDAO(ordersCollection);

        insertUsers();

        findAndPrintUsers();
// Path: src/main/java/shopJava/model/Order.java
// public class Order {
// 
//     private static final String ID = "_id";
//     private static final String USERNAME = "first";
//     private static final String AMOUNT = "amount";
// 
//     public final int id;
//     public final String username;
//     public final int amount;
// 
//     public Order(final int id, final String username, final int amount) {
//         this.id = id;
//         this.username = username;
//         this.amount = amount;
//     }
// 
//     public Order(final Document doc) {
//         this(doc.getInteger(ID), doc.getString(USERNAME), doc.getInteger(AMOUNT));
//     }
// 
//     @Override
//     public String toString() {
//         return "Order{" +
//                 ID + "=" + id +
//                 ", " + USERNAME + "='" + username + '\'' +
//                 ", " + AMOUNT + "=" + (amount/100.0) +
//                 '}';
//     }
// 
//     public void print() {
//         System.out.print(this);
//     }
// 
//     public void println() {
//         System.out.println(this);
//     }
// 
//     public Document toDocument() {
//         return new Document(ID, id).append(USERNAME, username).append(AMOUNT, amount);
//     }
// }
// 
// Path: src/main/java/shopJava/model/User.java
// public class User {
// 
//     private static final String ID = "_id";
//     private static final String NAME = "name";
//     private static final String PASSWORD = "password";
// 
//     public final String name;
//     public final String password;
// 
//     public User(final String name, final String password) {
//         this.name = name;
//         this.password = password;
//     }
// 
//     public User(Document doc) {
//         this(doc.getString(ID), doc.getString(PASSWORD));
//     }
// 
//     @Override
//     public String toString() {
//         return "User{" +
//                 NAME + "='" + name + '\'' +
//                 ", " + PASSWORD + "='" + password + '\'' +
//                 '}';
//     }
// 
//     public void print() {
//         System.out.print(this);
//     }
// 
//     public void println() {
//         System.out.println(this);
//     }
// 
//     public Document toDocument() {
//         return new Document(ID, name).append(PASSWORD, password);
//     }
// }
// 
// Path: src/main/java/shopJava/util/Constants.java
// public interface Constants {
// 
//     int MAX_ORDERS_PER_USER = 10;
// 
//     String MONGODB_URI = "mongodb://localhost:27017";
//     String SHOP_DB_NAME = "shop";
//     String USERS_COLLECTION_NAME = "users";
//     String ORDERS_COLLECTION_NAME = "orders";
// 
//     String HOMER = "homer";
//     String MARGE = "marge";
//     String BART = "bart";
//     String LISA = "lisa";
//     String MAGGIE = "maggie";
// 
//     String[] SIMPSONS = {HOMER, MARGE, BART, LISA, MAGGIE};
// }


// Path: src/main/java/shopJava/create/InsertUsersOrders.java
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import shopJava.model.Order;
import shopJava.model.User;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import static com.mongodb.client.model.Filters.eq;
import static java.util.stream.Collectors.toList;
import static shopJava.util.Constants.*;

    }
}

public class InsertUsersOrders {

    public static void main(String[] args) {
        new InsertUsersOrders();
    }

    private final Random random = new Random();

    private final UserDAO userDAO;
    private final OrderDAO orderDAO;

    public InsertUsersOrders() {

        final MongoClient client = new MongoClient(new MongoClientURI(MONGODB_URI));
        final  MongoDatabase db = client.getDatabase(SHOP_DB_NAME);

        final MongoCollection<Document> usersCollection = db.getCollection(USERS_COLLECTION_NAME);
        usersCollection.drop();
        userDAO = new UserDAO(usersCollection);

        final MongoCollection<Document> ordersCollection = db.getCollection(ORDERS_COLLECTION_NAME);
        ordersCollection.drop();
        orderDAO = new OrderDAO(ordersCollection);

        insertUsers();

        findAndPrintUsers();
        System.out.println();