Ejemplo n.º 1
0
        public void addStoreMannegerWithManagerPermission()
        {
            zahiOwner.addManagerPermission(zahi, "addStoreManager", store, "aviad");
            int ans = aviadManeger.addStoreManager(aviad, store, "shay");

            Assert.IsTrue(ans > -1);
            Assert.AreEqual(store.getManagers().Count, 2);
        }
        public void init()
        {
            WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB();
            cDB.emptyDB();
            ProductManager.restartInstance();
            SalesManager.restartInstance();
            StoreManagement.restartInstance();
            UserManager.restartInstance();
            UserCartsManager.restartInstance();
            BuyHistoryManager.restartInstance();
            CouponsManager.restartInstance();
            DiscountsManager.restartInstance();
            RaffleSalesManager.restartInstance();
            StorePremissionsArchive.restartInstance();
            us = userServices.getInstance();
            ss = storeServices.getInstance();

            partislav = us.startSession();
            us.register(partislav, "partislav", "123456");
            us.login(partislav, "partislav", "123456");

            manager1 = us.startSession();
            us.register(manager1, "manager1", "123456");
            us.login(manager1, "manager1", "123456");

            manager2 = us.startSession();
            us.register(manager2, "manager2", "123456");
            us.login(manager2, "manager2", "123456");

            int sId  = ss.createStore("makolet", partislav);
            int s2Id = ss.createStore("makolet", partislav);

            s  = StoreManagement.getInstance().getStore(sId);
            s2 = StoreManagement.getInstance().getStore(s2Id);

            ownerRole  = StoreRole.getStoreRole(s, partislav);
            ownerRole2 = StoreRole.getStoreRole(s, partislav);

            ownerRole.addStoreManager(partislav, s, "manager1");
            ownerRole.addStoreManager(partislav, s, "manager2");
            ownerRole.addStoreManager(partislav, s2, "manager1");
            ownerRole.addStoreManager(partislav, s2, "manager2");
        }
Ejemplo n.º 3
0
        public void removeStoreMannegerWithManagerPermission()
        {
            zahiOwner.addStoreManager(zahi, store, "shay");
            zahiOwner.addManagerPermission(zahi, "removeStoreManager", store, "shay");
            StoreManager shaymanneger = new StoreManager(shay, store);

            Assert.IsTrue(shaymanneger.removeStoreManager(shay, store, "aviad") > -1);
            Assert.AreEqual(store.getManagers().Count, 1);
        }
Ejemplo n.º 4
0
        //req 3.4 a

        /*
         * return:
         *           0 on sucess
         *          -1 if user Not Login
         *          -2 if new manager name not exist
         *          -3 if illegal store id
         *          -4 if don't have premition
         *          -5 database eror
         *          -6 already owner or manneger
         */
        public int addStoreManager(int sId, String newManager, User session)
        {
            Store     s  = StoreManagement.getInstance().getStore(sId);
            StoreRole sR = StoreRole.getStoreRole(s, session);

            if (sR == null)
            {
                return(-4);//-4 if don't have premition
            }
            return(sR.addStoreManager(session, s, newManager));
        }
Ejemplo n.º 5
0
        public void init()
        {
            WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB();
            cDB.emptyDB();
            ProductManager.restartInstance();
            SalesManager.restartInstance();
            StoreManagement.restartInstance();
            UserManager.restartInstance();
            UserCartsManager.restartInstance();
            StorePremissionsArchive.restartInstance();

            BuyHistoryManager.restartInstance();
            CouponsManager.restartInstance();
            DiscountsManager.restartInstance();
            RaffleSalesManager.restartInstance();
            StorePremissionsArchive.restartInstance();
            zahi = new User("zahi", "123456");
            zahi.register("zahi", "123456");
            zahi.login("zahi", "123456");
            aviad = new User("aviad", "123456");
            aviad.register("aviad", "123456");
            aviad.login("aviad", "123456");
            shay = new User("shay", "123456");
            shay.register("shay", "123456");
            shay.login("shay", "123456");
            itamar = new User("itamar", "123456");
            niv    = new User("niv", "123456");
            niv.register("niv", "123456");
            int storeId = zahi.createStore("abowim");

            store = StoreManagement.getInstance().getStore(storeId);
            int storeId2 = zahi.createStore("broes");

            store2    = StoreManagement.getInstance().getStore(storeId2);
            zahiOwner = new StoreOwner(zahi, store);

            aviadManeger = new StoreManager(aviad, store);
            zahiOwner.addStoreManager(zahi, store, "aviad");
            niv.logOut();
            int colaId = zahiOwner.addProductInStore(zahi, store, "cola", 3.2, 40, "Drinks");

            cola = ProductManager.getInstance().getProductInStore(colaId);
        }
Ejemplo n.º 6
0
 public void RemoveMangerFromStoreAsMannegerWithoutPremition()
 {
     zahiOwner.addStoreManager(zahi, store, "niv");
     Assert.IsFalse(aviadManeger.removeStoreManager(aviad, store, "niv") > -1);
     Assert.AreEqual(store.getManagers().Count, 2);
 }