diff --git a/apps/structure/core/src/main/java/com/adobe/dx/structure/flex/FlexModel.java b/apps/structure/core/src/main/java/com/adobe/dx/structure/flex/FlexModel.java index b929142e..8a95f4ea 100644 --- a/apps/structure/core/src/main/java/com/adobe/dx/structure/flex/FlexModel.java +++ b/apps/structure/core/src/main/java/com/adobe/dx/structure/flex/FlexModel.java @@ -32,14 +32,10 @@ public class FlexModel { protected SlingHttpServletRequest request; @OSGiService - protected IDTagger idTagger; + IDTagger idTagger; String id; - public String getHello() { - return "Hello"; - } - public boolean isStyleNeeded() { return true; } diff --git a/apps/structure/core/src/test/java/com/adobe/dx/structure/flex/FlexModelTest.java b/apps/structure/core/src/test/java/com/adobe/dx/structure/flex/FlexModelTest.java index 76688e2a..3b032de7 100644 --- a/apps/structure/core/src/test/java/com/adobe/dx/structure/flex/FlexModelTest.java +++ b/apps/structure/core/src/test/java/com/adobe/dx/structure/flex/FlexModelTest.java @@ -16,15 +16,41 @@ package com.adobe.dx.structure.flex; import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import com.adobe.dx.domtagging.IDTagger; import com.adobe.dx.testing.AbstractRequestModelTest; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; class FlexModelTest extends AbstractRequestModelTest { + FlexModel model; + + @BeforeEach + public void setup() throws ReflectiveOperationException { + context.build().resource(CONTENT_ROOT,"title", "flex test").commit(); + model = getModel(FlexModel.class, CONTENT_ROOT); + } + + @Test + public void testWorkingId() { + model.idTagger = mock(IDTagger.class); + when(model.idTagger.computeComponentId(any(), any())).thenReturn("blah"); + assertEquals("blah", model.getId()); + } + + @Test + public void testNonWorkingId() { + assertNull(model.getId()); + } + + @Test - void getHello() throws ReflectiveOperationException { - assertEquals("Hello", getModel(FlexModel.class).getHello()); + public void testIsNeeded() throws ReflectiveOperationException { + assertTrue(model.isStyleNeeded()); } } \ No newline at end of file