1 Reply Latest reply on Jul 28, 2015 9:53 AM by Matous Jobanek

    JavaArchive.class question. The custom Mapper logic through Orika. How to create right Deployment archive with Orika artifact?

    aLEX dAN Newbie

      Hello,

      I am using Arquillian framework for my tests. Now i have the problem when i want to test my Mapper classes. I can not add Orika to my jar file or i don't know how to do that properly. Please, help.

       

      I have the following createDeployment method in the AbstractMapperTest class:

       

      @Deployment
          public static JavaArchive createDeployment() {
              return ShrinkWrap.create(JavaArchive.class, "test.jar")
                      .addPackage(Mapper.class.getPackage())
                      .addPackage(AbstractMapperTest.class.getPackage())
                      .addPackage(MapperImpl.class.getPackage())
                      .addPackage(SomeDTO.class.getPackage())    
                      .addPackage(SomeEntity.class.getPackage())
                      .addPackages(true, "ma.glasnost")
                      .addPackages(true, "com.thoughtworks")
                      .addPackages(true, "com.googlecode")
                      .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
          }
      

       

      Maven dependency:

          <!-- Orika Mapper -->
              <dependency>
                  <groupId>ma.glasnost.orika</groupId>
                  <artifactId>orika-core</artifactId>
                  <version>1.4.6</version>
              </dependency>
           <!--Strange dependency that i need for deployment file creation-->
              <dependency>
                  <groupId>com.thoughtworks.paranamer</groupId>
                  <artifactId>paranamer</artifactId>
                  <version>2.7</version>
              </dependency>
              <dependency>
                  <groupId>com.googlecode.concurrentlinkedhashmap</groupId>
                  <artifactId>concurrentlinkedhashmap-lru</artifactId>
                  <version>1.4.2</version>
              </dependency>
      

       

      And simple test:

      @RunWith(Arquillian.class)
      public class ActivityMapperTest extends AbstractMapperTest {
          @Inject
          private ActivityMapper activityMapper;
          @Test
          public void getActivityMapper_existentActivityMapper_notNullMapperFactory() {
              Assert.assertThat(activityMapper, is(notNullValue()));
              Assert.assertThat(activityMapper.getMapperFactory(), is(notNullValue()));
          }
      }
      

       

      And this works fine.

       

      But for what reason i need to add this lines of the code in the deployment method and additional dependency for maven? Please, suggest how i can add Orika artifacts properly through maven.

      .addPackages(true, "ma.glasnost")
      .addPackages(true, "com.thoughtworks")
      .addPackages(true, "com.googlecode")
      

       

      Thanks,

      Alex