forked from agoncal/agoncal-application-petstore-ee6
/
AddressTest.java
executable file
·53 lines (41 loc) · 1.53 KB
/
AddressTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package org.agoncal.application.petstore.domain;
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.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import javax.validation.Validator;
import static org.junit.Assert.assertEquals;
/**
* @author Antonio Goncalves
*/
@RunWith(Arquillian.class)
public class AddressTest {
// ======================================
// = Attributes =
// ======================================
@Inject
private Validator validator;
// ======================================
// = Lifecycle Methods =
// ======================================
@Deployment
public static JavaArchive jar() {
return ShrinkWrap.create(JavaArchive.class)
.addClass(Address.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
// ======================================
// = Methods =
// ======================================
@Test
public void shouldCreateAValidAddress() {
// Creates an object
Address address = new Address("Street1", "City", "Zipcode", "Country");
// Checks the object is valid
assertEquals("Should have not constraint violation", 0, validator.validate(address).size());
}
}