• jimmy_sf
  • NEWBIE
  • 5 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

Hi,

 

I've got a good amount of apex code which is only executed when some draft KnowledgeArticleVersions exist.  I understand that we cannot create KnowledgeArticleVersions from apex coce, so I'm not sure how to get test coverage on that code which requires presence of draft KnowledgeArticleVersions.

 

Despite the presece of knowledge article drafts in my (prerelease) org, none are present in the test context.

 

Is there some way to work around these restrictions to get test coverage?

 

Best,

-jimmy 

I've run across some odd knowledge article behavior.  My KnowledgeAticleVersion soql querys are not working with variable substitution:

 

// Fails with comile error 

String languageCode = 'es';

List<KnowledgeArticleVersion> foo = [select MasterVersionId, Title, Language from KnowledgeArticleVersion where PublishStatus = 'Draft' and Language =: languageCode and IsMasterLanguage = false] ;

 

// Works fine

List<KnowledgeArticleVersion> foo = [select MasterVersionId, Title, Language from KnowledgeArticleVersion where PublishStatus = 'Draft' and Language = 'es' and IsMasterLanguage = false] ;

 

Shouldn't the first example work? 

 

Best,

-james 

Hi,

 

I've got a good amount of apex code which is only executed when some draft KnowledgeArticleVersions exist.  I understand that we cannot create KnowledgeArticleVersions from apex coce, so I'm not sure how to get test coverage on that code which requires presence of draft KnowledgeArticleVersions.

 

Despite the presece of knowledge article drafts in my (prerelease) org, none are present in the test context.

 

Is there some way to work around these restrictions to get test coverage?

 

Best,

-jimmy 

I've run across some odd knowledge article behavior.  My KnowledgeAticleVersion soql querys are not working with variable substitution:

 

// Fails with comile error 

String languageCode = 'es';

List<KnowledgeArticleVersion> foo = [select MasterVersionId, Title, Language from KnowledgeArticleVersion where PublishStatus = 'Draft' and Language =: languageCode and IsMasterLanguage = false] ;

 

// Works fine

List<KnowledgeArticleVersion> foo = [select MasterVersionId, Title, Language from KnowledgeArticleVersion where PublishStatus = 'Draft' and Language = 'es' and IsMasterLanguage = false] ;

 

Shouldn't the first example work? 

 

Best,

-james 

How do i resolve this...This is my code...I am sending an XML to an endpoint n number of times(its in a for loop)...Cant i do that?

public PageReference saveUsers() {
String[] listOfSelectedUsers = getUsers();
String domainId = System.currentPageReference().getParameters().get('ex');
for(String presentVar: listOfSelectedUsers)
{

Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://84.40.30.147/cm/spws');
req.setMethod('POST');

TestExtranet__c extranet = [select Extranet_Name__c from TestExtranet__c where id = :domainId];
Lead lead = [select id,firstname,lastname,email from Lead where id = :presentVar];
String requestXML = buildXMLRequest('createUser',extranet.Extranet_Name__c,lead.id,lead.firstname,lead.lastname,lead.email);

req.setBody(requestXML);
HttpResponse res = h.send(req);
XmlStreamReader reader = res.getXmlStreamReader();
boolean errorExists = parseResponseForError(reader);
if(!errorExists)
{
Extranet_User_Mapping__c mapping = new Extranet_User_Mapping__c();
mapping.Extranet_Id__c = domainId;
mapping.Leads__c = presentVar;
insert mapping;
}else
{

}


}
PageReference userConfPage = new PageReference('/apex/userConfirmation?ex='+ System.currentPageReference().getParameters().get('ex'));
return Page.userConfirmation;
}