Hi All,
We have created Junit5 class for the below code.
We covered all line except 40, 47 and 48, can anyone help to cover line no 40, 47 and 48?
Test Class:-
import io.wcm.testing.mock.aem.junit5.AemContext;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;
import org.apache.sling.api.resource.Resource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ExtendWith(AemContextExtension.class)
public class RedirectionModelTest {
AemContext context = new AemContext();
@BeforeEach
public void setUp() throws Exception{
context.create().page("/content/mykp/en");
Resource resource = context.resourceResolver().getResource("/content/mykp/en");
context.request().setAttribute("redirectURL", "/content/mykp/homepage");
context.currentResource(resource);
context.request().adaptTo(RedirectionModel.class);
}
@Test
public void init() {
assertEquals("/content/mykp/homepage.html",context.response().getHeader("location"));
}
}