Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. package com.living.features.arquillian;
  2.  
  3. import static org.hamcrest.Matchers.equalTo;
  4. import static org.hamcrest.Matchers.hasItems;
  5. import static org.hamcrest.Matchers.hasProperty;
  6. import static org.hamcrest.Matchers.hasSize;
  7. import static org.junit.Assert.assertThat;
  8. import static org.junit.Assert.fail;
  9. import java.util.Arrays;
  10.  
  11. import javax.inject.Inject;
  12.  
  13. import org.jboss.arquillian.container.test.api.Deployment;
  14. import org.jboss.arquillian.junit.Arquillian;
  15. import org.jboss.shrinkwrap.api.ShrinkWrap;
  16. import org.jboss.shrinkwrap.api.gradle.archive.importer.embedded.EmbeddedGradleImporter;
  17. import org.jboss.shrinkwrap.api.spec.JavaArchive;
  18. import org.jboss.shrinkwrap.api.spec.WebArchive;
  19. import org.jboss.shrinkwrap.resolver.api.maven.Maven;
  20. import org.junit.Test;
  21. import org.junit.runner.RunWith;
  22.  
  23. import com.living.authz.oauth.persistence.repository.exceptions.RepositorySystemException;
  24. import com.living.mock.ArquillianAlternative;
  25. import com.living.mock.MockFactory;
  26. import com.living.rest.dto.FollowUpActivityDTO;
  27. import com.living.rest.dto.metainfos.values.MetaInfoValueDTO;
  28. import com.living.rest.dto.metainfos.values.StringMetaInfoValue;
  29. import com.living.rest.services.FollowUpActivityService;
  30. import com.living.rest.services.ResourceService;
  31.  
  32. @RunWith(Arquillian.class)
  33. public class ArquillianTest
  34. {
  35.  
  36. @Inject protected FollowUpActivityService fuaService;
  37. @Inject protected ResourceService resourceService;
  38.  
  39. @Deployment
  40. public static WebArchive createDeployment()
  41. {
  42. System.getProperties().remove("javax.xml.parsers.SAXParserFactory");
  43. EmbeddedGradleImporter importer = ShrinkWrap.create(EmbeddedGradleImporter.class);
  44. WebArchive war = importer.forThisProjectDirectory().importBuildOutput().as(WebArchive.class);
  45.  
  46. war.addClass(ArquillianAlternative.class);
  47. war.addClass(MockFactory.class);
  48.  
  49. JavaArchive[] libs = Maven.resolver().resolve("org.mockito:mockito-core:2.0.31-beta").withTransitivity().as(JavaArchive.class);
  50. war.addAsLibraries(libs);
  51.  
  52. //System.out.println(war.toString(true));
  53.  
  54. return war;
  55. }
  56.  
  57. @Test
  58. public void categorize()
  59. {
  60. FollowUpActivityDTO receivedFuaDTO = new FollowUpActivityDTO();
  61. receivedFuaDTO.setId("idFuaCategorize");
  62.  
  63. MetaInfoValueDTO receivedMetaInfoValue = new StringMetaInfoValue("key", "value");
  64.  
  65. try {
  66. this.fuaService.createOrUpdate(receivedFuaDTO);
  67. this.fuaService.categorize(Arrays.asList(receivedFuaDTO.getId()), Arrays.asList(receivedMetaInfoValue));
  68.  
  69. FollowUpActivityDTO categorizedFuaDto = this.fuaService.findOne(receivedFuaDTO.getId());
  70. assertThat(categorizedFuaDto.getMetainfos(), hasSize(1));
  71.  
  72. assertThat(categorizedFuaDto.getMetainfos(), hasItems(
  73. hasProperty("key", equalTo(receivedMetaInfoValue.getKey())),
  74. hasProperty("value", equalTo(receivedMetaInfoValue.getValue()))
  75. ));
  76.  
  77. } catch (RepositorySystemException e) {
  78. fail(e.getMessage());
  79. }
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement