- Pankaj IRT
- NEWBIE
- 15 Points
- Member since 2015
- Consultant
- IRT Computer Solutions (India) Pvt. Ltd.
-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
9Questions
-
11Replies
Test Cases And Test Class
Hi Everyone ,
Please Suggest me best covarage logic for this
This is my class
public with sharing class CreateQuoteController {
public List<Product2> packageProductsList = new List<Product2>();
public List<ProductWrapper> searchResultsWithWrapper {get;set;}
public List<QuoteLineItem> quoteItemsList {get;set;}
public Quote_Package__c quotePackage {get;set;}
public CreateQuoteController (){
//Get record id of Quote Package
ID quotePackageId = ApexPages.currentPage().getParameters().get('id');
//Read Package Details based on Record ID
quotePackage = [Select Id, Name, Package__c, Physchem_Subpackage__c, Quote__c, Quote__r.CurrencyISOCode from Quote_Package__c where Id =:quotePackageId ];
//Fetch All Products matching with Package
packageProductsList = [Select Id, Name, ProductCode, Description, Package__c, Physchem_Subpackage__c , CIPAC__c,
EC__c, OECD__c, OPPTS__c from Product2 where isActive = true and Package__c = :quotePackage.Package__c ];
if(packageProductsList != null){
//A list of ProductWrapper class that wraps Product2 class to enable checkbox selection
searchResultsWithWrapper = new List<ProductWrapper>();
if(quotePackage.Physchem_Subpackage__c != null && quotePackage.Physchem_Subpackage__c != ''){
//Add only those products in Search Result where Product Physchem subpackage matches with that selected in Quote Package
for(Product2 product:packageProductsList ){
String productPhysChemSubpackage = product.Physchem_Subpackage__c;
if(productPhysChemSubpackage != null && productPhysChemSubpackage != '' && productPhysChemSubpackage.contains(quotePackage.Physchem_Subpackage__c)){
searchResultsWithWrapper.add(new ProductWrapper(product));
}
}
}else{
//Add All products in Search Result
for(Product2 product:packageProductsList ){
searchResultsWithWrapper.add(new ProductWrapper(product));
}
}
}
}
public PageReference proceedToConfigure()
{
Map<String, String> productIdMap = new Map<String, String>();
Map<String, Decimal> productIdPriceMap = new Map<String, Decimal>();
Map<String, String> productIdPriceBookEntryIdMap = new Map<String, String>();
for(ProductWrapper productWrapper : searchResultsWithWrapper){
if(productWrapper.selected){
productIdMap.put(productWrapper.product.Id, productWrapper.product.Id);
}
//Fetch Standard Price book entries of Selected product to later add in Quote Line Item
List<PriceBookEntry> priceBookEntries = [Select Id, Product2Id,Product2.CIPAC__c,
Product2.EC__c, Product2.OECD__c,Product2.OPPTS__c, UnitPrice, CurrencyIsoCode
from PriceBookEntry where Pricebook2.IsStandard = true
and Product2.isActive = true and Product2Id in :productIdMap.keySet()
and CurrencyIsoCode = :quotePackage.Quote__r.CurrencyISOCode];
//Create a Map of Product Id and PriceBookEntry Id for later use
if(priceBookEntries != null){
for(PriceBookEntry priceBookEntry : priceBookEntries ){
productIdPriceMap.put(priceBookEntry.Product2Id , priceBookEntry.UnitPrice);
productIdPriceBookEntryIdMap.put(priceBookEntry.Product2Id , priceBookEntry.Id);
}
}
}
quoteItemsList = new List<QuoteLineItem>();
for(ProductWrapper productWrapper : searchResultsWithWrapper){
//For Every product selected, create a Quote Line Item to show for Configuration
if(productWrapper.selected){
QuoteLineItem quoteLineItem = new QuoteLineItem();
quoteLineItem.Product2Id = productWrapper.product.Id;
quoteLineItem.Quote_Package__c = quotePackage.Id;
quoteLineItem.QuoteId = quotePackage.Quote__c;
quoteLineItem.Quantity = 1;
quoteLineItem.Description = productWrapper.product.Description;
quoteLineItem.UnitPrice = productIdPriceMap.get(productWrapper.product.Id);
quoteLineItem.PricebookEntryId = productIdPriceBookEntryIdMap.get(productWrapper.product.Id);
quoteLineItem.Product2 = productWrapper.product;
quoteItemsList.add(quoteLineItem);
}
}
PageReference pageRef = new PageReference('/apex/configureQuoteLineItems');
return pageRef;
}
public PageReference addItemsToPackage()
{
try
{
PriceBook2 standardPriceBook = [Select Id from PriceBook2 where IsStandard = true];
Quote quote = new Quote(Id=quoteItemsList[0].QuoteId);
quote.Pricebook2Id = standardPriceBook.Id;
update quote;
//insert configured Quote line items, so that they appear against Quote Package as well as Quote
insert quoteItemsList;
return new PageReference('/'+quoteItemsList[0].Quote_Package__c);
}catch(DMLException e){
ApexPages.addMessages(e);
return null;
}
}
public PageReference cancel()
{
return new PageReference('/'+quotePackage.Id);
}
public PageReference backToSelectProducts()
{
return new PageReference('/apex/selectProductsPage?id='+quotePackage.Id);
}
public class ProductWrapper{
public Product2 product{get;set;}
public boolean selected{get;set;}
public ProductWrapper(Product2 p){
product= p;
selected = false;
}
}
}
Please Suggest me best covarage logic for this
This is my class
public with sharing class CreateQuoteController {
public List<Product2> packageProductsList = new List<Product2>();
public List<ProductWrapper> searchResultsWithWrapper {get;set;}
public List<QuoteLineItem> quoteItemsList {get;set;}
public Quote_Package__c quotePackage {get;set;}
public CreateQuoteController (){
//Get record id of Quote Package
ID quotePackageId = ApexPages.currentPage().getParameters().get('id');
//Read Package Details based on Record ID
quotePackage = [Select Id, Name, Package__c, Physchem_Subpackage__c, Quote__c, Quote__r.CurrencyISOCode from Quote_Package__c where Id =:quotePackageId ];
//Fetch All Products matching with Package
packageProductsList = [Select Id, Name, ProductCode, Description, Package__c, Physchem_Subpackage__c , CIPAC__c,
EC__c, OECD__c, OPPTS__c from Product2 where isActive = true and Package__c = :quotePackage.Package__c ];
if(packageProductsList != null){
//A list of ProductWrapper class that wraps Product2 class to enable checkbox selection
searchResultsWithWrapper = new List<ProductWrapper>();
if(quotePackage.Physchem_Subpackage__c != null && quotePackage.Physchem_Subpackage__c != ''){
//Add only those products in Search Result where Product Physchem subpackage matches with that selected in Quote Package
for(Product2 product:packageProductsList ){
String productPhysChemSubpackage = product.Physchem_Subpackage__c;
if(productPhysChemSubpackage != null && productPhysChemSubpackage != '' && productPhysChemSubpackage.contains(quotePackage.Physchem_Subpackage__c)){
searchResultsWithWrapper.add(new ProductWrapper(product));
}
}
}else{
//Add All products in Search Result
for(Product2 product:packageProductsList ){
searchResultsWithWrapper.add(new ProductWrapper(product));
}
}
}
}
public PageReference proceedToConfigure()
{
Map<String, String> productIdMap = new Map<String, String>();
Map<String, Decimal> productIdPriceMap = new Map<String, Decimal>();
Map<String, String> productIdPriceBookEntryIdMap = new Map<String, String>();
for(ProductWrapper productWrapper : searchResultsWithWrapper){
if(productWrapper.selected){
productIdMap.put(productWrapper.product.Id, productWrapper.product.Id);
}
//Fetch Standard Price book entries of Selected product to later add in Quote Line Item
List<PriceBookEntry> priceBookEntries = [Select Id, Product2Id,Product2.CIPAC__c,
Product2.EC__c, Product2.OECD__c,Product2.OPPTS__c, UnitPrice, CurrencyIsoCode
from PriceBookEntry where Pricebook2.IsStandard = true
and Product2.isActive = true and Product2Id in :productIdMap.keySet()
and CurrencyIsoCode = :quotePackage.Quote__r.CurrencyISOCode];
//Create a Map of Product Id and PriceBookEntry Id for later use
if(priceBookEntries != null){
for(PriceBookEntry priceBookEntry : priceBookEntries ){
productIdPriceMap.put(priceBookEntry.Product2Id , priceBookEntry.UnitPrice);
productIdPriceBookEntryIdMap.put(priceBookEntry.Product2Id , priceBookEntry.Id);
}
}
}
quoteItemsList = new List<QuoteLineItem>();
for(ProductWrapper productWrapper : searchResultsWithWrapper){
//For Every product selected, create a Quote Line Item to show for Configuration
if(productWrapper.selected){
QuoteLineItem quoteLineItem = new QuoteLineItem();
quoteLineItem.Product2Id = productWrapper.product.Id;
quoteLineItem.Quote_Package__c = quotePackage.Id;
quoteLineItem.QuoteId = quotePackage.Quote__c;
quoteLineItem.Quantity = 1;
quoteLineItem.Description = productWrapper.product.Description;
quoteLineItem.UnitPrice = productIdPriceMap.get(productWrapper.product.Id);
quoteLineItem.PricebookEntryId = productIdPriceBookEntryIdMap.get(productWrapper.product.Id);
quoteLineItem.Product2 = productWrapper.product;
quoteItemsList.add(quoteLineItem);
}
}
PageReference pageRef = new PageReference('/apex/configureQuoteLineItems');
return pageRef;
}
public PageReference addItemsToPackage()
{
try
{
PriceBook2 standardPriceBook = [Select Id from PriceBook2 where IsStandard = true];
Quote quote = new Quote(Id=quoteItemsList[0].QuoteId);
quote.Pricebook2Id = standardPriceBook.Id;
update quote;
//insert configured Quote line items, so that they appear against Quote Package as well as Quote
insert quoteItemsList;
return new PageReference('/'+quoteItemsList[0].Quote_Package__c);
}catch(DMLException e){
ApexPages.addMessages(e);
return null;
}
}
public PageReference cancel()
{
return new PageReference('/'+quotePackage.Id);
}
public PageReference backToSelectProducts()
{
return new PageReference('/apex/selectProductsPage?id='+quotePackage.Id);
}
public class ProductWrapper{
public Product2 product{get;set;}
public boolean selected{get;set;}
public ProductWrapper(Product2 p){
product= p;
selected = false;
}
}
}
- Pankaj IRT
- October 23, 2015
- Like
- 0
- Continue reading or reply
- Pankaj IRT
- October 13, 2015
- Like
- 0
- Continue reading or reply
Insert event field in email template
I want to displqy events field on email template. so plz help me or suggest what can i do to print any of field may be standard or custom in email template
- Pankaj IRT
- September 26, 2015
- Like
- 1
- Continue reading or reply
Insert event field in email template
I want to displqy events field on email template. so plz help me or suggest what can i do to print any of field may be standard or custom in email template
- Pankaj IRT
- September 26, 2015
- Like
- 1
- Continue reading or reply
Test Cases And Test Class
Hi Everyone ,
Please Suggest me best covarage logic for this
This is my class
public with sharing class CreateQuoteController {
public List<Product2> packageProductsList = new List<Product2>();
public List<ProductWrapper> searchResultsWithWrapper {get;set;}
public List<QuoteLineItem> quoteItemsList {get;set;}
public Quote_Package__c quotePackage {get;set;}
public CreateQuoteController (){
//Get record id of Quote Package
ID quotePackageId = ApexPages.currentPage().getParameters().get('id');
//Read Package Details based on Record ID
quotePackage = [Select Id, Name, Package__c, Physchem_Subpackage__c, Quote__c, Quote__r.CurrencyISOCode from Quote_Package__c where Id =:quotePackageId ];
//Fetch All Products matching with Package
packageProductsList = [Select Id, Name, ProductCode, Description, Package__c, Physchem_Subpackage__c , CIPAC__c,
EC__c, OECD__c, OPPTS__c from Product2 where isActive = true and Package__c = :quotePackage.Package__c ];
if(packageProductsList != null){
//A list of ProductWrapper class that wraps Product2 class to enable checkbox selection
searchResultsWithWrapper = new List<ProductWrapper>();
if(quotePackage.Physchem_Subpackage__c != null && quotePackage.Physchem_Subpackage__c != ''){
//Add only those products in Search Result where Product Physchem subpackage matches with that selected in Quote Package
for(Product2 product:packageProductsList ){
String productPhysChemSubpackage = product.Physchem_Subpackage__c;
if(productPhysChemSubpackage != null && productPhysChemSubpackage != '' && productPhysChemSubpackage.contains(quotePackage.Physchem_Subpackage__c)){
searchResultsWithWrapper.add(new ProductWrapper(product));
}
}
}else{
//Add All products in Search Result
for(Product2 product:packageProductsList ){
searchResultsWithWrapper.add(new ProductWrapper(product));
}
}
}
}
public PageReference proceedToConfigure()
{
Map<String, String> productIdMap = new Map<String, String>();
Map<String, Decimal> productIdPriceMap = new Map<String, Decimal>();
Map<String, String> productIdPriceBookEntryIdMap = new Map<String, String>();
for(ProductWrapper productWrapper : searchResultsWithWrapper){
if(productWrapper.selected){
productIdMap.put(productWrapper.product.Id, productWrapper.product.Id);
}
//Fetch Standard Price book entries of Selected product to later add in Quote Line Item
List<PriceBookEntry> priceBookEntries = [Select Id, Product2Id,Product2.CIPAC__c,
Product2.EC__c, Product2.OECD__c,Product2.OPPTS__c, UnitPrice, CurrencyIsoCode
from PriceBookEntry where Pricebook2.IsStandard = true
and Product2.isActive = true and Product2Id in :productIdMap.keySet()
and CurrencyIsoCode = :quotePackage.Quote__r.CurrencyISOCode];
//Create a Map of Product Id and PriceBookEntry Id for later use
if(priceBookEntries != null){
for(PriceBookEntry priceBookEntry : priceBookEntries ){
productIdPriceMap.put(priceBookEntry.Product2Id , priceBookEntry.UnitPrice);
productIdPriceBookEntryIdMap.put(priceBookEntry.Product2Id , priceBookEntry.Id);
}
}
}
quoteItemsList = new List<QuoteLineItem>();
for(ProductWrapper productWrapper : searchResultsWithWrapper){
//For Every product selected, create a Quote Line Item to show for Configuration
if(productWrapper.selected){
QuoteLineItem quoteLineItem = new QuoteLineItem();
quoteLineItem.Product2Id = productWrapper.product.Id;
quoteLineItem.Quote_Package__c = quotePackage.Id;
quoteLineItem.QuoteId = quotePackage.Quote__c;
quoteLineItem.Quantity = 1;
quoteLineItem.Description = productWrapper.product.Description;
quoteLineItem.UnitPrice = productIdPriceMap.get(productWrapper.product.Id);
quoteLineItem.PricebookEntryId = productIdPriceBookEntryIdMap.get(productWrapper.product.Id);
quoteLineItem.Product2 = productWrapper.product;
quoteItemsList.add(quoteLineItem);
}
}
PageReference pageRef = new PageReference('/apex/configureQuoteLineItems');
return pageRef;
}
public PageReference addItemsToPackage()
{
try
{
PriceBook2 standardPriceBook = [Select Id from PriceBook2 where IsStandard = true];
Quote quote = new Quote(Id=quoteItemsList[0].QuoteId);
quote.Pricebook2Id = standardPriceBook.Id;
update quote;
//insert configured Quote line items, so that they appear against Quote Package as well as Quote
insert quoteItemsList;
return new PageReference('/'+quoteItemsList[0].Quote_Package__c);
}catch(DMLException e){
ApexPages.addMessages(e);
return null;
}
}
public PageReference cancel()
{
return new PageReference('/'+quotePackage.Id);
}
public PageReference backToSelectProducts()
{
return new PageReference('/apex/selectProductsPage?id='+quotePackage.Id);
}
public class ProductWrapper{
public Product2 product{get;set;}
public boolean selected{get;set;}
public ProductWrapper(Product2 p){
product= p;
selected = false;
}
}
}
Please Suggest me best covarage logic for this
This is my class
public with sharing class CreateQuoteController {
public List<Product2> packageProductsList = new List<Product2>();
public List<ProductWrapper> searchResultsWithWrapper {get;set;}
public List<QuoteLineItem> quoteItemsList {get;set;}
public Quote_Package__c quotePackage {get;set;}
public CreateQuoteController (){
//Get record id of Quote Package
ID quotePackageId = ApexPages.currentPage().getParameters().get('id');
//Read Package Details based on Record ID
quotePackage = [Select Id, Name, Package__c, Physchem_Subpackage__c, Quote__c, Quote__r.CurrencyISOCode from Quote_Package__c where Id =:quotePackageId ];
//Fetch All Products matching with Package
packageProductsList = [Select Id, Name, ProductCode, Description, Package__c, Physchem_Subpackage__c , CIPAC__c,
EC__c, OECD__c, OPPTS__c from Product2 where isActive = true and Package__c = :quotePackage.Package__c ];
if(packageProductsList != null){
//A list of ProductWrapper class that wraps Product2 class to enable checkbox selection
searchResultsWithWrapper = new List<ProductWrapper>();
if(quotePackage.Physchem_Subpackage__c != null && quotePackage.Physchem_Subpackage__c != ''){
//Add only those products in Search Result where Product Physchem subpackage matches with that selected in Quote Package
for(Product2 product:packageProductsList ){
String productPhysChemSubpackage = product.Physchem_Subpackage__c;
if(productPhysChemSubpackage != null && productPhysChemSubpackage != '' && productPhysChemSubpackage.contains(quotePackage.Physchem_Subpackage__c)){
searchResultsWithWrapper.add(new ProductWrapper(product));
}
}
}else{
//Add All products in Search Result
for(Product2 product:packageProductsList ){
searchResultsWithWrapper.add(new ProductWrapper(product));
}
}
}
}
public PageReference proceedToConfigure()
{
Map<String, String> productIdMap = new Map<String, String>();
Map<String, Decimal> productIdPriceMap = new Map<String, Decimal>();
Map<String, String> productIdPriceBookEntryIdMap = new Map<String, String>();
for(ProductWrapper productWrapper : searchResultsWithWrapper){
if(productWrapper.selected){
productIdMap.put(productWrapper.product.Id, productWrapper.product.Id);
}
//Fetch Standard Price book entries of Selected product to later add in Quote Line Item
List<PriceBookEntry> priceBookEntries = [Select Id, Product2Id,Product2.CIPAC__c,
Product2.EC__c, Product2.OECD__c,Product2.OPPTS__c, UnitPrice, CurrencyIsoCode
from PriceBookEntry where Pricebook2.IsStandard = true
and Product2.isActive = true and Product2Id in :productIdMap.keySet()
and CurrencyIsoCode = :quotePackage.Quote__r.CurrencyISOCode];
//Create a Map of Product Id and PriceBookEntry Id for later use
if(priceBookEntries != null){
for(PriceBookEntry priceBookEntry : priceBookEntries ){
productIdPriceMap.put(priceBookEntry.Product2Id , priceBookEntry.UnitPrice);
productIdPriceBookEntryIdMap.put(priceBookEntry.Product2Id , priceBookEntry.Id);
}
}
}
quoteItemsList = new List<QuoteLineItem>();
for(ProductWrapper productWrapper : searchResultsWithWrapper){
//For Every product selected, create a Quote Line Item to show for Configuration
if(productWrapper.selected){
QuoteLineItem quoteLineItem = new QuoteLineItem();
quoteLineItem.Product2Id = productWrapper.product.Id;
quoteLineItem.Quote_Package__c = quotePackage.Id;
quoteLineItem.QuoteId = quotePackage.Quote__c;
quoteLineItem.Quantity = 1;
quoteLineItem.Description = productWrapper.product.Description;
quoteLineItem.UnitPrice = productIdPriceMap.get(productWrapper.product.Id);
quoteLineItem.PricebookEntryId = productIdPriceBookEntryIdMap.get(productWrapper.product.Id);
quoteLineItem.Product2 = productWrapper.product;
quoteItemsList.add(quoteLineItem);
}
}
PageReference pageRef = new PageReference('/apex/configureQuoteLineItems');
return pageRef;
}
public PageReference addItemsToPackage()
{
try
{
PriceBook2 standardPriceBook = [Select Id from PriceBook2 where IsStandard = true];
Quote quote = new Quote(Id=quoteItemsList[0].QuoteId);
quote.Pricebook2Id = standardPriceBook.Id;
update quote;
//insert configured Quote line items, so that they appear against Quote Package as well as Quote
insert quoteItemsList;
return new PageReference('/'+quoteItemsList[0].Quote_Package__c);
}catch(DMLException e){
ApexPages.addMessages(e);
return null;
}
}
public PageReference cancel()
{
return new PageReference('/'+quotePackage.Id);
}
public PageReference backToSelectProducts()
{
return new PageReference('/apex/selectProductsPage?id='+quotePackage.Id);
}
public class ProductWrapper{
public Product2 product{get;set;}
public boolean selected{get;set;}
public ProductWrapper(Product2 p){
product= p;
selected = false;
}
}
}
- Pankaj IRT
- October 23, 2015
- Like
- 0
- Continue reading or reply
Insert event field in email template
I want to displqy events field on email template. so plz help me or suggest what can i do to print any of field may be standard or custom in email template
- Pankaj IRT
- September 26, 2015
- Like
- 1
- Continue reading or reply