Skip to content

Commit 8b9c55f

Browse files
Implemented plenty of Tests for specific Java Types
1 parent b7b32e2 commit 8b9c55f

33 files changed

Lines changed: 1328 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.isolatet.tests;
17+
18+
import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD;
19+
20+
import java.lang.annotation.ElementType;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
import org.junit.jupiter.api.extension.ExtendWith;
26+
import org.springframework.test.annotation.DirtiesContext;
27+
import org.springframework.test.context.ContextConfiguration;
28+
import org.springframework.test.context.junit.jupiter.SpringExtension;
29+
30+
31+
@Retention(RetentionPolicy.RUNTIME)
32+
@Target(ElementType.TYPE)
33+
@ExtendWith(SpringExtension.class)
34+
@ContextConfiguration(classes = {IsolatedTestConfiguration.class})
35+
@DirtiesContext(classMode = BEFORE_EACH_TEST_METHOD)
36+
public @interface IsolatedTestAnnotations
37+
{
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.isolatet.tests;
17+
18+
import java.nio.file.Path;
19+
20+
import org.springframework.beans.factory.DisposableBean;
21+
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.beans.factory.annotation.Value;
23+
import org.springframework.context.annotation.Configuration;
24+
import org.springframework.context.event.ContextRefreshedEvent;
25+
import org.springframework.context.event.EventListener;
26+
import org.springframework.util.FileSystemUtils;
27+
28+
import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage;
29+
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
30+
31+
32+
@Configuration
33+
@EnableEclipseStoreRepositories
34+
public class IsolatedTestConfiguration implements DisposableBean
35+
{
36+
@Autowired
37+
EclipseStoreStorage storage;
38+
39+
@Value("${org.eclipse.store.storage-directory}")
40+
private String storageDirectory;
41+
42+
@EventListener
43+
public void handleContextRefresh(final ContextRefreshedEvent event)
44+
{
45+
// Init with empty root object
46+
this.storage.clearData();
47+
}
48+
49+
@Override
50+
public void destroy() throws Exception
51+
{
52+
// End with empty root object
53+
this.storage.clearData();
54+
this.storage.stop();
55+
FileSystemUtils.deleteRecursively(Path.of(this.storageDirectory));
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.isolatet.tests.special.types;
17+
18+
import java.math.BigDecimal;
19+
import java.util.List;
20+
21+
22+
public class BigDecimalDaoObject extends ComplexObject<BigDecimal>
23+
{
24+
public BigDecimalDaoObject(final Integer id, final BigDecimal value)
25+
{
26+
super(id, value);
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.isolatet.tests.special.types;
17+
18+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository;
19+
20+
21+
public interface BigDecimalRepository extends EclipseStoreRepository<BigDecimalDaoObject, Integer>
22+
{
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.isolatet.tests.special.types;
17+
18+
import java.math.BigDecimal;
19+
import java.math.BigInteger;
20+
21+
22+
public class BigIntegerDaoObject extends ComplexObject<BigInteger>
23+
{
24+
public BigIntegerDaoObject(final Integer id, final BigInteger value)
25+
{
26+
super(id, value);
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.isolatet.tests.special.types;
17+
18+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository;
19+
20+
21+
public interface BigIntegerRepository extends EclipseStoreRepository<BigIntegerDaoObject, Integer>
22+
{
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.isolatet.tests.special.types;
17+
18+
import java.util.Calendar;
19+
20+
21+
public class CalendarDaoObject extends ComplexObject<Calendar>
22+
{
23+
public CalendarDaoObject(final Integer id, final Calendar value)
24+
{
25+
super(id, value);
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.isolatet.tests.special.types;
17+
18+
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository;
19+
20+
21+
public interface CalendarRepository extends EclipseStoreRepository<CalendarDaoObject, Integer>
22+
{
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.isolatet.tests.special.types;
17+
18+
import java.util.Objects;
19+
20+
import jakarta.persistence.Id;
21+
22+
23+
public class ComplexObject<T>
24+
{
25+
@Id
26+
private final Integer id;
27+
28+
private T value;
29+
30+
public ComplexObject(final Integer id, final T value)
31+
{
32+
this.id = id;
33+
this.value = value;
34+
}
35+
36+
public T getValue()
37+
{
38+
return this.value;
39+
}
40+
41+
public void setValue(final T value)
42+
{
43+
this.value = value;
44+
}
45+
46+
public Integer getId()
47+
{
48+
return this.id;
49+
}
50+
51+
@Override
52+
public boolean equals(final Object o)
53+
{
54+
if(this == o)
55+
{
56+
return true;
57+
}
58+
if(o == null || this.getClass() != o.getClass())
59+
{
60+
return false;
61+
}
62+
final ComplexObject<?> that = (ComplexObject<?>)o;
63+
return Objects.equals(this.id, that.id) && Objects.equals(this.value, that.value);
64+
}
65+
66+
@Override
67+
public int hashCode()
68+
{
69+
return Objects.hash(this.id, this.value);
70+
}
71+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.integration.isolatet.tests.special.types;
17+
18+
import java.util.Date;
19+
20+
21+
public class DateDaoObject extends ComplexObject<Date>
22+
{
23+
public DateDaoObject(final Integer id, final Date value)
24+
{
25+
super(id, value);
26+
}
27+
}

0 commit comments

Comments
 (0)