| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package com.xpn.xwiki.internal.model.reference; |
| 21 |
|
|
| 22 |
|
import org.junit.Before; |
| 23 |
|
import org.junit.Rule; |
| 24 |
|
import org.junit.Test; |
| 25 |
|
import org.xwiki.model.EntityType; |
| 26 |
|
import org.xwiki.model.reference.AttachmentReference; |
| 27 |
|
import org.xwiki.model.reference.DocumentReference; |
| 28 |
|
import org.xwiki.model.reference.EntityReference; |
| 29 |
|
import org.xwiki.model.reference.EntityReferenceResolver; |
| 30 |
|
import org.xwiki.model.reference.SpaceReference; |
| 31 |
|
import org.xwiki.model.reference.WikiReference; |
| 32 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
| 33 |
|
|
| 34 |
|
import static org.junit.Assert.assertEquals; |
| 35 |
|
import static org.mockito.Mockito.when; |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
@link |
| 39 |
|
|
| 40 |
|
@version |
| 41 |
|
@since |
| 42 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 43 |
|
public class CurrentAttachmentReferenceResolverTest |
| 44 |
|
{ |
| 45 |
|
@Rule |
| 46 |
|
public MockitoComponentMockingRule<CurrentAttachmentReferenceResolver> mocker = |
| 47 |
|
new MockitoComponentMockingRule<>(CurrentAttachmentReferenceResolver.class); |
| 48 |
|
|
| 49 |
|
private EntityReferenceResolver<EntityReference> entityReferenceResolver; |
| 50 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 51 |
1 |
@Before... |
| 52 |
|
public void SetUp() throws Exception |
| 53 |
|
{ |
| 54 |
1 |
entityReferenceResolver = mocker.getInstance(EntityReferenceResolver.TYPE_REFERENCE, "current"); |
| 55 |
|
} |
| 56 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
| 57 |
1 |
@Test... |
| 58 |
|
public void resolveTest() throws Exception |
| 59 |
|
{ |
| 60 |
|
|
| 61 |
1 |
EntityReference entityReference = new EntityReference("hello.txt", EntityType.ATTACHMENT); |
| 62 |
|
|
| 63 |
1 |
AttachmentReference attachmentReference = new AttachmentReference("hello.txt", |
| 64 |
|
new DocumentReference("Document", new SpaceReference("Space", new WikiReference("wiki")))); |
| 65 |
|
|
| 66 |
1 |
when(entityReferenceResolver.resolve(entityReference, EntityType.ATTACHMENT)).thenReturn(attachmentReference); |
| 67 |
|
|
| 68 |
|
|
| 69 |
1 |
AttachmentReference result = mocker.getComponentUnderTest().resolve(entityReference); |
| 70 |
|
|
| 71 |
|
|
| 72 |
1 |
assertEquals(attachmentReference, result); |
| 73 |
|
} |
| 74 |
|
} |