1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sourceforge.domian.repository;
17
18
19 import java.util.ArrayList;
20 import java.util.Collection;
21 import java.util.List;
22
23 import org.junit.Test;
24
25 import org.apache.commons.lang.NotImplementedException;
26
27 import net.sourceforge.domian.entity.Entity;
28 import static net.sourceforge.domian.specification.SpecificationFactory.all;
29 import static net.sourceforge.domian.specification.SpecificationFactory.allEntities;
30 import static net.sourceforge.domian.specification.SpecificationFactory.createSpecificationFor;
31 import static net.sourceforge.domian.specification.SpecificationFactory.the;
32 import net.sourceforge.domian.test.domain.Customer;
33 import static net.sourceforge.domian.test.domain.Testdata.femaleCustomer;
34 import static net.sourceforge.domian.test.domain.Testdata.maleCustomer;
35
36
37 public class NotImplementedRepositoryTest extends AbstractRepositoryTestCase {
38
39 @Override
40 protected String getTestRepoRootPath() {
41 throw new UnsupportedOperationException(NOT_APPLICABLE_METHOD_MESSAGE);
42 }
43
44 @Override
45 protected <T extends Entity> Repository<T> getRepository() {
46 return new NotImplementedRepository<T>();
47 }
48
49 @Override
50 protected <T extends Entity> Repository<T> getRepository(Class<T> entityType, String repositoryId) {
51 throw new UnsupportedOperationException(NOT_APPLICABLE_METHOD_MESSAGE);
52 }
53
54
55
56
57
58
59
60
61 @Override
62 protected <T extends Entity> PersistentRepository<T> getPersistentRepository(String repositoryId, PersistenceDefinition persistenceDefinition) {
63 throw new UnsupportedOperationException(NOT_APPLICABLE_METHOD_MESSAGE);
64 }
65
66 @Override
67 protected <T extends Entity> PartitionRepository<T> getPartitionRepository() {
68 throw new UnsupportedOperationException(NOT_APPLICABLE_METHOD_MESSAGE);
69 }
70
71 @Override
72 protected <T extends Entity> PartitionRepository<T> getPartitionRepository(Class<T> entityType, String repositoryId) {
73 throw new UnsupportedOperationException(NOT_APPLICABLE_METHOD_MESSAGE);
74 }
75
76 @Override
77 protected <R extends Repository<? extends Entity>> void reset(R repository, int maxNumberOfEntitiesToPurge) {}
78
79 @Override
80 protected List<PersistenceDefinition> getSupportedPersistenceDefinitions() {
81 throw new UnsupportedOperationException(NOT_APPLICABLE_METHOD_MESSAGE);
82 }
83
84 @Test(expected = NotImplementedException.class)
85 public void shouldThrowExceptionForCountAllEntities() {
86 getRepository().count(allEntities());
87 }
88
89 @Test(expected = NotImplementedException.class)
90 public void shouldThrowExceptionForCountAllEntitiesSpecifiedBy() {
91 getRepository().countAllEntitiesSpecifiedBy(createSpecificationFor(Customer.class));
92 }
93
94 @Test(expected = NotImplementedException.class)
95 public void shouldThrowExceptionForCount() {
96 getRepository().count(all(Customer.class));
97 }
98
99 @Test(expected = NotImplementedException.class)
100 public void shouldThrowExceptionForFindAllEntitiesSpecifiedBy() {
101 getRepository().findAllEntitiesSpecifiedBy(createSpecificationFor(Customer.class));
102 }
103
104 @Test(expected = NotImplementedException.class)
105 public void shouldThrowExceptionForFind() {
106 getRepository().findAll(all(Customer.class));
107 }
108
109 @Test(expected = NotImplementedException.class)
110 public void shouldThrowExceptionForFindSingleEntitiespecifiedBy() {
111 getRepository().findSingleEntitySpecifiedBy(createSpecificationFor(Customer.class));
112 }
113
114 @Test(expected = NotImplementedException.class)
115 public void shouldThrowExceptionForFindSingle() {
116 getRepository().findSingle(the(Customer.class));
117 }
118
119 @Test(expected = NotImplementedException.class)
120 public void shouldThrowExceptionForPut() {
121 getRepository().put(maleCustomer);
122 }
123
124 @Test(expected = NotImplementedException.class)
125 public void shouldThrowExceptionForPutAll() {
126 Collection<Customer> customers = new ArrayList<Customer>();
127 customers.add(maleCustomer);
128 customers.add(femaleCustomer);
129 getRepository().putAll(customers);
130 }
131
132 @Test(expected = NotImplementedException.class)
133 public void shouldThrowExceptionForRemoveAllEntities() {
134 getRepository().remove(allEntities());
135 }
136
137 @Test(expected = NotImplementedException.class)
138 public void shouldThrowExceptionForRemoveAllEntitiesSpecifiedBy() {
139 getRepository().removeAllEntitiesSpecifiedBy(createSpecificationFor(Customer.class));
140 }
141
142 @Test(expected = NotImplementedException.class)
143 public void shouldThrowExceptionForRemoveAll() {
144 getRepository().removeAll(all(Customer.class));
145 }
146
147 @Test(expected = NotImplementedException.class)
148 public void shouldThrowExceptionForRemove() {
149 getRepository().remove(maleCustomer);
150 }
151 }