Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.living.features.arquillian;
- import static org.hamcrest.Matchers.equalTo;
- import static org.hamcrest.Matchers.hasItems;
- import static org.hamcrest.Matchers.hasProperty;
- import static org.hamcrest.Matchers.hasSize;
- import static org.junit.Assert.assertThat;
- import static org.junit.Assert.fail;
- import java.util.Arrays;
- import javax.inject.Inject;
- import org.jboss.arquillian.container.test.api.Deployment;
- import org.jboss.arquillian.junit.Arquillian;
- import org.jboss.shrinkwrap.api.ShrinkWrap;
- import org.jboss.shrinkwrap.api.gradle.archive.importer.embedded.EmbeddedGradleImporter;
- import org.jboss.shrinkwrap.api.spec.JavaArchive;
- import org.jboss.shrinkwrap.api.spec.WebArchive;
- import org.jboss.shrinkwrap.resolver.api.maven.Maven;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import com.living.authz.oauth.persistence.repository.exceptions.RepositorySystemException;
- import com.living.mock.ArquillianAlternative;
- import com.living.mock.MockFactory;
- import com.living.rest.dto.FollowUpActivityDTO;
- import com.living.rest.dto.metainfos.values.MetaInfoValueDTO;
- import com.living.rest.dto.metainfos.values.StringMetaInfoValue;
- import com.living.rest.services.FollowUpActivityService;
- import com.living.rest.services.ResourceService;
- @RunWith(Arquillian.class)
- public class ArquillianTest
- {
- @Inject protected FollowUpActivityService fuaService;
- @Inject protected ResourceService resourceService;
- @Deployment
- public static WebArchive createDeployment()
- {
- System.getProperties().remove("javax.xml.parsers.SAXParserFactory");
- EmbeddedGradleImporter importer = ShrinkWrap.create(EmbeddedGradleImporter.class);
- WebArchive war = importer.forThisProjectDirectory().importBuildOutput().as(WebArchive.class);
- war.addClass(ArquillianAlternative.class);
- war.addClass(MockFactory.class);
- JavaArchive[] libs = Maven.resolver().resolve("org.mockito:mockito-core:2.0.31-beta").withTransitivity().as(JavaArchive.class);
- war.addAsLibraries(libs);
- //System.out.println(war.toString(true));
- return war;
- }
- @Test
- public void categorize()
- {
- FollowUpActivityDTO receivedFuaDTO = new FollowUpActivityDTO();
- receivedFuaDTO.setId("idFuaCategorize");
- MetaInfoValueDTO receivedMetaInfoValue = new StringMetaInfoValue("key", "value");
- try {
- this.fuaService.createOrUpdate(receivedFuaDTO);
- this.fuaService.categorize(Arrays.asList(receivedFuaDTO.getId()), Arrays.asList(receivedMetaInfoValue));
- FollowUpActivityDTO categorizedFuaDto = this.fuaService.findOne(receivedFuaDTO.getId());
- assertThat(categorizedFuaDto.getMetainfos(), hasSize(1));
- assertThat(categorizedFuaDto.getMetainfos(), hasItems(
- hasProperty("key", equalTo(receivedMetaInfoValue.getKey())),
- hasProperty("value", equalTo(receivedMetaInfoValue.getValue()))
- ));
- } catch (RepositorySystemException e) {
- fail(e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement