public void ensureFromCollectionReturnsModelViewIfCollectionIsValid()
        {
            CustomizedProductCollection customizedProductCollection =
                createCustomizedProductCollection();

            CustomizedProductCollection otherCustomizedProductCollection =
                createCustomizedProductCollection();

            GetAllCustomizedProductCollectionsModelView expectedModelView =
                new GetAllCustomizedProductCollectionsModelView();

            expectedModelView =
                new GetAllCustomizedProductCollectionsModelView()
            {
                CustomizedProductCollectionModelViewService.fromEntityAsBasic(customizedProductCollection),
                CustomizedProductCollectionModelViewService.fromEntityAsBasic(otherCustomizedProductCollection)
            };

            List <CustomizedProductCollection> collection =
                new List <CustomizedProductCollection>()
            {
                customizedProductCollection, otherCustomizedProductCollection
            };

            GetAllCustomizedProductCollectionsModelView actualModelView =
                CustomizedProductCollectionModelViewService.fromCollection(collection);

            assertBasicModelView(expectedModelView[0], actualModelView[0]);
            assertBasicModelView(expectedModelView[1], actualModelView[1]);
        }
        public void ensureFromEntityReturnsModelViewIfEntityIsValid()
        {
            CustomizedProductCollection customizedProductCollection =
                createCustomizedProductCollection();

            GetCustomizedProductCollectionModelView expectedModelView =
                new GetCustomizedProductCollectionModelView();

            expectedModelView.name = customizedProductCollection.name;
            expectedModelView.customizedProducts = new List <GetBasicCustomizedProductModelView>();
            expectedModelView.customizedProducts.Add(new GetBasicCustomizedProductModelView());
            expectedModelView.customizedProducts[0].designation =
                customizedProductCollection.collectionProducts[0].customizedProduct.designation;
            expectedModelView.customizedProducts[0].reference =
                customizedProductCollection.collectionProducts[0].customizedProduct.reference;
            expectedModelView.customizedProducts[0].productId =
                customizedProductCollection.collectionProducts[0].customizedProduct.product.Id;

            GetCustomizedProductCollectionModelView actualModelView =
                CustomizedProductCollectionModelViewService.fromEntity(customizedProductCollection);

            Assert.Equal(expectedModelView.name, actualModelView.name);
            Assert.Equal(expectedModelView.customizedProducts[0].designation,
                         actualModelView.customizedProducts[0].designation);
            Assert.Equal(expectedModelView.customizedProducts[0].reference,
                         actualModelView.customizedProducts[0].reference);
            Assert.Equal(expectedModelView.customizedProducts[0].productId,
                         actualModelView.customizedProducts[0].productId);
        }
Exemple #3
0
        /// <summary>
        /// Fetches a customized product collection by its entity identifier
        /// </summary>
        /// <param name="modelView">CustomizedProductCollectionDTO with the customized product collection information</param>
        /// <returns>CustomizedProductCollectionDTO with the fetched customized product collection information</returns>
        public GetCustomizedProductCollectionModelView findCollectionByEID(GetCustomizedProductCollectionModelView modelView)
        {
            CustomizedProductCollection collection = PersistenceContext.repositories().createCustomizedProductCollectionRepository().find(modelView.name);

            if (collection == null)
            {
                throw new ResourceNotFoundException(string.Format(UNABLE_TO_FIND_COLLECTION_BY_NAME, modelView.name));
            }

            return(CustomizedProductCollectionModelViewService.fromEntity(collection));
        }
Exemple #4
0
        /// <summary>
        /// Fetches all available customized products collections
        /// </summary>
        /// <returns>List with all available customized products collections</returns>
        public GetAllCustomizedProductCollectionsModelView findAllCollections()
        {
            IEnumerable <CustomizedProductCollection> collections = PersistenceContext.repositories().createCustomizedProductCollectionRepository().findAll();

            if (!collections.Any())
            {
                throw new ResourceNotFoundException(NO_COLLECTIONS_AVAILABLE);
            }

            return(CustomizedProductCollectionModelViewService.fromCollection(collections));
        }
        public void ensureFromEntityAsBasicReturnsBasicModelViewIfEntityIsValid()
        {
            CustomizedProductCollection customizedProductCollection =
                createCustomizedProductCollection();

            GetBasicCustomizedProductCollectionModelView expectedModelView =
                new GetBasicCustomizedProductCollectionModelView();

            expectedModelView.name = customizedProductCollection.name;
            expectedModelView.hasCustomizedProducts = customizedProductCollection.collectionProducts.Count != 0;

            GetBasicCustomizedProductCollectionModelView actualModelView =
                CustomizedProductCollectionModelViewService.fromEntityAsBasic(customizedProductCollection);

            assertBasicModelView(expectedModelView, actualModelView);
        }
Exemple #6
0
        /// <summary>
        /// Adds a new customized products collection
        /// </summary>
        /// <param name="modelView">CustomizedProductCollectionDTO with the customized product collection information</param>
        /// <returns>CustomizedProductCollectionDTO with the created customized product collection information</returns>
        public GetCustomizedProductCollectionModelView addCollection(AddCustomizedProductCollectionModelView modelView)
        {
            CustomizedProductCollection customizedProductCollection = CreateCustomizedProductCollectionService.create(modelView);

            return(CustomizedProductCollectionModelViewService.fromEntity(customizedProductCollection));
        }
Exemple #7
0
        /// <summary>
        /// Adds a customized product to the customized product collection
        /// </summary>
        /// <param name="modelView">UpdateCustomizedProductCollectionDTO with the customized product collection information</param>
        /// <returns>boolean true if the customized product was successfully added, false if not</returns>
        public GetCustomizedProductCollectionModelView addCustomizedProductToCustomizedProductCollection(AddCustomizedProductToCustomizedProductCollectionModelView modelView)
        {
            CustomizedProductCollection updatedCustomizedProductCollection = UpdateCustomizedProductCollectionService.update(modelView);

            return(CustomizedProductCollectionModelViewService.fromEntity(updatedCustomizedProductCollection));
        }
Exemple #8
0
        /// <summary>
        /// Updates basic information of a customized product collection
        /// </summary>
        /// <param name="modelView">UpdateCustomizedProductCollectionDTO with the customized product collection update information</param>
        /// <returns>boolean true if the update was successful, false if not</returns>
        public GetBasicCustomizedProductCollectionModelView updateCollectionBasicInformation(UpdateCustomizedProductCollectionModelView modelView)
        {
            CustomizedProductCollection updatedCustomizedProductCollection = UpdateCustomizedProductCollectionService.update(modelView);

            return(CustomizedProductCollectionModelViewService.fromEntityAsBasic(updatedCustomizedProductCollection));
        }
 public void ensureFromCollectionThrowsExceptionIfCollectionIsNull()
 {
     Assert.Throws <ArgumentNullException>(
         () => CustomizedProductCollectionModelViewService.fromCollection(null));
 }
 public void ensureFromEntityAsBasicThrowsExceptionIfEntityIsNull()
 {
     Assert.Throws <ArgumentNullException>(
         () => CustomizedProductCollectionModelViewService.fromEntityAsBasic(null));
 }