mardi 24 mai 2016

Can someone help me to write JUnit for the below Java class in PowerMockito

Can someone help me to write JUnit for the below Java class in PowerMockito. I have written the below class to access the date present in page properties to the metadata. However metadata is added in head.html

import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.sling.api.resource.ValueMap;
import com.adobe.cq.sightly.WCMUse;
import com.day.cq.wcm.api.Page;

public class TrainingDate extends WCMUse{
    private Page pg;
    private String check;
    public void activate() throws Exception{
        pg =  getCurrentPage();
        Date date 
            = pg.getProperties().get("trainingdate",Date.class);

        SimpleDateFormat sdf 
            = new SimpleDateFormat("MM-dd-YYYY");
        check = sdf.format(date);
    }

    public String getCheck(){       
    return check;
    }
}

Aucun commentaire:

Enregistrer un commentaire