Skip to content

Commit

Permalink
adobeGH-24 fix UT coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
npeltier committed Sep 14, 2020
1 parent 1dae249 commit ee97faa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit ee97faa

Please sign in to comment.