• Francesco Carmagnola 9
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
Since my last deployment, which passed, the coverage of my company is rated 64 percent if I run all tests. If I try to deploy something, the coverage is rated 72%. How is that possible?
I've got this piece of code:

for (String key : mapADXadUnit.keySet()) {
            system.debug('@@key ' + key);
            String keywrapper = mapADXadUnit_wrappers_key.get(key);
            
            Asset tempasset = new Asset();
            Product2 prod = new Product2();
            tempasset.product2 = prod;
            
            tempasset.Name = key;
            Integer trovato = 0;
            
            for(AdUnit__c ad: alladunit){
                String path_query = ad.Path__c;
                path_query = path_query.deleteWhitespace();
                system.debug('@@adunit path '+  ' - ' + path_query + ' - wrapper: ' + mapADXadUnit_path.get(key)); //+ mapADXadUnit_path.get(key));
                if(path_query == mapADXadUnit_path.get(key)){
                system.debug('@@trovat '+  ' - ' + path_query + ' - wrapper: ' + mapADXadUnit_path.get(key));
                tempasset.AdUnit__c = ad.Id;
                tempasset.year__c = year;
                tempasset.month__c = mapMonths.get(Integer.valueOf(month));
                tempasset.adUnitView__c = 'FLAT';
                tempasset.Line_Item__c =  mapADXadUnit_LI.get(key).Id;
                tempasset.Product2 =  [SELECT Id FROM product2 WHERE Id =:mapADXadUnit_LI.get(key).Product__r.id];
                
                try{
                    system.debug('@@product: ' + mapADXadUnit_LI.get(key).Product__r.id);
                    //tempasset.Product2.Id =  mapADXadUnit_LI.get(key).Product__r.id;
                } catch (exception e){
                    system.debug(e.getMessage());
                    system.debug('@@product_errore: '+ key + ' >> ' + mapADXadUnit_LI.get(key).Product__r.id);
                }
                tempasset.Impressions__c = mapADXadUnit.get(key)[2];
                trovato = 1;
                break;
                }
            }
            
            if(trovato != 1){
            wrappers.get(keywrapper).setError('Problemi con gli Asset: non è possibile trovare adUnit con il path indicato nel file');
            }
            //system.debug('@tempassetproduct ' + tempasset.Product2.Id);
            system.debug('@tempasset keywrapper: '+ keywrapper + ':::::::: tempasset: '+ tempasset);
            if(mapListAssetToInsert.get(keywrapper) == null){
                mapListAssetToInsert.put(keywrapper, new List<Asset>{tempasset});
            } else{
                mapListAssetToInsert.get(keywrapper).add(tempasset);
            }
        }
        
            for(string key: mapListAssetToInsert.keyset()){
            system.debug('@@mapListAssetToInsert: ' + key + ' - ' + mapListAssetToInsert.get(key));
            }

Now, the strange thing is the output. The record "tempasset" seems to be correct every cycle:

18:15:44.373 (3373776808)|USER_DEBUG|[431]|DEBUG|@tempasset keywrapper: 123asd123asd - 300x250&#124;&#124; tempasset: Asset:{Name=123asd123asd - 300x250 - BLOG > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVnzAAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}

18:15:44.404 (3404302842)|USER_DEBUG|[431]|DEBUG|@tempasset keywrapper: 123asd123asd - 500x300&#124;&#124; tempasset: Asset:{Name=123asd123asd - 500x300 - BLOG > ros, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVotAAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od9oAAC, Impressions__c=10.0}

18:15:44.424 (3424780098)|USER_DEBUG|[431]|DEBUG|@tempasset keywrapper: 123asd123asd - 300x250&#124;&#124; tempasset: Asset:{Name=123asd123asd - 300x250 - Buonissimo > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVo0AAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}

But the map where I write this record it's quite strange and has three times the same record, the last one:

18:15:44.425 (3425647410)|USER_DEBUG|[440]|DEBUG|@@mapListAssetToInsert: 123asd123asd - 300x250 - (Asset:{Name=123asd123asd - 300x250 - Buonissimo > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVo0AAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 300x250 - Buonissimo > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVo0AAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 300x250 - Buonissimo > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVo0AAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 300x250 - Buonissimo > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVo0AAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 300x250 - BLOG > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVnzAAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 300x250 - Buonissimo > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVo0AAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 300x250 - BLOG > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVnzAAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 300x250 - Buonissimo > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVo0AAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 300x250 - BLOG > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVnzAAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 300x250 - Buonissimo > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVo0AAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}, ...)


18:15:44.426 (3426045158)|USER_DEBUG|[440]|DEBUG|@@mapListAssetToInsert: 123asd123asd - 500x300 - (Asset:{Name=123asd123asd - 300x250 - Buonissimo > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVo0AAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 300x250 - Buonissimo > hp, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVo0AAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od7nAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 500x300 - BLOG > ros, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVotAAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od9oAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 500x300 - BLOG > ros, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVotAAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od9oAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 500x300 - BLOG > ros, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVotAAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od9oAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 500x300 - BLOG > ros, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVotAAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od9oAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 500x300 - BLOG > ros, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVotAAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od9oAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 500x300 - BLOG > ros, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVotAAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od9oAAC, Impressions__c=10.0}, Asset:{Name=123asd123asd - 500x300 - BLOG > ros, Month__c=Marzo, Year__c=2015, AdUnit__c=a0011000001LVotAAG, adUnitView__c=FLAT, Line_Item__c=a0811000004Od9oAAC, Impressions__c=10.0})

Have you got any idea?

Thanks!