/
IntegrationRepositoryTest.java
80 lines (69 loc) · 3.03 KB
/
IntegrationRepositoryTest.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Copyright © 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.management;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.groups.Tuple.*;
import io.gravitee.common.utils.UUID;
import io.gravitee.repository.exceptions.TechnicalException;
import io.gravitee.repository.management.api.search.builder.PageableBuilder;
import io.gravitee.repository.management.model.Integration;
import java.util.Date;
import java.util.List;
import org.junit.Test;
public class IntegrationRepositoryTest extends AbstractManagementRepositoryTest {
@Override
protected String getTestCasesPath() {
return "/data/integration-tests/";
}
@Test
public void shouldCreate() throws TechnicalException {
var date = new Date();
var uuid = UUID.random().toString();
Integration integration = Integration
.builder()
.id(uuid)
.name("my-name")
.description("my-description")
.provider("my_provider")
.environmentId("my-env")
.createdAt(date)
.updatedAt(date)
.build();
Integration createdIntegration = integrationRepository.create(integration);
assertThat(createdIntegration).isEqualTo(integration);
}
@Test
public void shouldFindByEnvironmentId() throws TechnicalException {
final List<Integration> integrations = integrationRepository
.findAllByEnvironment("my-env", new PageableBuilder().pageSize(10).pageNumber(0).build())
.getContent();
assertThat(integrations)
.hasSize(3)
.extracting(Integration::getId, Integration::getName, Integration::getDescription, Integration::getEnvironmentId)
.contains(
tuple("cad107c9-27f2-40b2-9107-c927f2e0b2fc", "my-integration", "test-description", "my-env"),
tuple("f66274c9-3d8f-44c5-a274-c93d8fb4c5f3", "my-another-integration", "test-description", "my-env"),
tuple("459a022c-e79c-4411-9a02-2ce79c141165", "my-yet-another-integration", "test-description", "my-env")
);
}
@Test
public void shouldReturnEmptyListWhenEnvironmentIdNotFound() throws TechnicalException {
final List<Integration> integrations = integrationRepository
.findAllByEnvironment("other-env", new PageableBuilder().pageSize(10).pageNumber(0).build())
.getContent();
assertThat(integrations).hasSize(0);
}
}