1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.extension.maven.internal.converter

File ArtifactModelConverterTest.java

 

Code metrics

0
19
4
1
95
54
4
0.21
4.75
4
1

Classes

Class Line # Actions
ArtifactModelConverterTest 41 19 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.extension.maven.internal.converter;
21   
22    import org.apache.maven.model.Model;
23    import org.junit.jupiter.api.BeforeEach;
24    import org.junit.jupiter.api.Test;
25    import org.xwiki.extension.Extension;
26    import org.xwiki.extension.maven.ArtifactModel;
27    import org.xwiki.properties.internal.DefaultConverterManager;
28    import org.xwiki.test.annotation.AllComponents;
29    import org.xwiki.test.junit5.mockito.ComponentTest;
30    import org.xwiki.test.junit5.mockito.InjectMockComponents;
31   
32    import static org.junit.jupiter.api.Assertions.assertEquals;
33   
34    /**
35    * Validate {@link ModelConverter} component.
36    *
37    * @version $Id: 11cbec84ad439d9816cb9be62c7dca28b3335398 $
38    */
39    @ComponentTest
40    @AllComponents
 
41    public class ArtifactModelConverterTest
42    {
43    @InjectMockComponents
44    private DefaultConverterManager converter;
45   
46    private ArtifactModel artifactModel;
47   
 
48  3 toggle @BeforeEach
49    public void beforeEach()
50    {
51  3 Model model = new Model();
52   
53  3 model.setGroupId("groupid");
54  3 model.setArtifactId("artifactid");
55  3 model.setVersion("version");
56  3 model.setPackaging("pom");
57   
58  3 this.artifactModel = new ArtifactModel(model);
59    }
60   
 
61  1 toggle @Test
62    public void testConvertWithClassifier() throws SecurityException
63    {
64  1 this.artifactModel.setClassifier("classifier");
65   
66  1 Extension extension = this.converter.convert(Extension.class, artifactModel);
67   
68  1 assertEquals("groupid:artifactid:classifier", extension.getId().getId());
69  1 assertEquals("pom", extension.getType());
70    }
71   
 
72  1 toggle @Test
73    public void testConvertWithType() throws SecurityException
74    {
75  1 this.artifactModel.setType("type");
76   
77  1 Extension extension = this.converter.convert(Extension.class, artifactModel);
78   
79  1 assertEquals("groupid:artifactid", extension.getId().getId());
80  1 assertEquals("type", extension.getType());
81    }
82   
 
83  1 toggle @Test
84    public void testConvertWithClassifierAndType() throws SecurityException
85    {
86  1 this.artifactModel.setClassifier("classifier");
87  1 this.artifactModel.setType("type");
88   
89  1 Extension extension = this.converter.convert(Extension.class, artifactModel);
90   
91  1 assertEquals("groupid:artifactid:classifier", extension.getId().getId());
92  1 assertEquals("type", extension.getType());
93    }
94   
95    }