package com.aem.core.models;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.lenient;
import java.util.List;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.factory.ModelFactory;
import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import io.wcm.testing.mock.aem.junit5.AemContext;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;
@ExtendWith({ AemContextExtension.class, MockitoExtension.class })
public class TextWithCtaModelTest {
final AemContext ctx = new AemContext();
@Mock
private ModelFactory modelFactory;
@Mock
private List<LinkModel> actionsList;
// TextWithCtaModel textWithCtaModel;
@BeforeEach
void setUp() throws Exception {
ctx.addModelsForClasses(TextWithCtaModel.class);
ctx.load().json("/com/firstdata/aem/core/models/TextWithCtaModelTest.json", "/content");
lenient().when(modelFactory.getModelFromWrappedRequest(eq(ctx.request()), any(Resource.class), eq(List.class)))
.thenReturn(actionsList);
}
@Test
void testGetContentView() {
Resource myResource = ctx.resourceResolver().getResource("/content/textwithcta");
TextWithCtaModel textWithCtaModel = ctx.getService(ModelFactory.class).createModel(myResource,
TextWithCtaModel.class);
final String expected = "Testing Content";
final String actual = textWithCtaModel.getContentView();
assertEquals(expected, actual);
}
@Test
void testValidate() {
}
}