Commit e8779c7b authored by Kristel Meikas's avatar Kristel Meikas
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Kristel Meikas

See merge request teis/officials-service!68
parents cbb0aea6 124c1629
......@@ -4,6 +4,8 @@ stages:
- deploy
- cve-test
image: docker.repo.tehik.ee/gradle:jdk17
variables:
USE_POSTGRES: "true"
USE_RABBIT: "true"
......
# Changelog
## [2.0.0] - 2022-08-12
* Upgraded to java 17, gradle 7.4.2, spring boot 2.6.8 and others; uses TEIS Gradle plugin 2.3.0
## [1.15.0] - 2022-05-20
* TEIS-3057: new endpoint for creating official in sequence
......
......@@ -20,34 +20,24 @@ buildscript {
}
apply plugin: 'ee.sm.ti.teis'
allprojects {
group = "${theGroup}"
version = "${theVersion}"
apply from: this.getClass().getClassLoader().getResource('teis.sonarqube.gradle')
}
subprojects {
apply plugin: 'ee.sm.ti.teis'
functionalities{
functionalities {
base
}
repositories {
mavenLocal()
maven {
url "${gradle.ext.artifactoryUrl}/${gradle.ext.artifactoryRepoKey}"
credentials {
username = "${gradle.ext.artifactoryUser}"
password = "${gradle.ext.artifactoryPass}"
}
}
jcenter()
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
apply from: this.getClass().getClassLoader().getResource('teis.test-sonar.gradle')
group = "${theGroup}"
version = "${theVersion}"
sourceCompatibility = 11
targetCompatibility = 11
jar {
manifest {
attributes('Implementation-Title': project.name,
......@@ -55,9 +45,6 @@ allprojects {
}
}
dependencies {
compile "ee.sm.ti.teis:office-api-gateway-lib:${officeApiGatewayVersion}"
compile "ee.sm.ti.teis:service-common-lib:${commonsVersion}"
compile "ee.sm.ti.teis:domain-cache-lib:${commonsVersion}"
}
apply from: this.getClass().getClassLoader().getResource('teis.test-jacoco.gradle')
}
theGroup=ee.sm.ti.teis
theVersion=1.15.0
commonsVersion=1.36.0
officeApiGatewayVersion=1.37.0
pluginVersion=1.5.0
theVersion=2.0.0
commonsVersion=2.6.0
officeApiGatewayVersion=2.5.0
pluginVersion=2.3.0
#Fri Mar 08 15:54:50 EET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://repo.tehik.ee/artifactory/gradle-distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://repo.tehik.ee/artifactory/gradle-distributions/gradle-5.6.4-bin.zip
......@@ -8,11 +8,11 @@ functionalities {
apply from: this.getClass().getClassLoader().getResource('teis.integrationTest.gradle')
apply from: this.getClass().getClassLoader().getResource('teis.microservice.gradle')
dependencies {
implementation "ee.sm.ti.teis:office-api-gateway-lib:${officeApiGatewayVersion}"
implementation "ee.sm.ti.teis:service-common-lib:${commonsVersion}"
implementation "ee.sm.ti.teis:domain-cache-lib:${commonsVersion}"
}
// Define the main class for the application
mainClassName = 'ee.sm.ti.teis.OfficialsServiceApp'
test {
testLogging {
events "passed", "skipped", "failed"
}
}
gradle.ext.artifactoryUrl = hasProperty('ARTIFACTORY_URL') ? ARTIFACTORY_URL : System.getenv('ARTIFACTORY_URL')
gradle.ext.artifactoryUser = hasProperty('ARTIFACTORY_USER') ? ARTIFACTORY_USER : System.getenv('ARTIFACTORY_USER')
gradle.ext.artifactoryPass = hasProperty('ARTIFACTORY_PASS') ? ARTIFACTORY_PASS : System.getenv('ARTIFACTORY_PASS')
gradle.ext.artifactoryRepoKey = hasProperty('ARTIFACTORY_REPO_KEY') ? ARTIFACTORY_REPO_KEY : System.getenv('ARTIFACTORY_REPO_KEY')
rootProject.name='officials-service'
......@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
public class OfficialsGroupManagerServiceTest extends OfficialsAppTestBase {
class OfficialsGroupManagerServiceTest extends OfficialsAppTestBase {
private static final UUID USER_ID = UUID.fromString("50d9b9a6-93d9-469b-9d53-7063a7467d7f");
......@@ -61,4 +61,5 @@ public class OfficialsGroupManagerServiceTest extends OfficialsAppTestBase {
verify(msRabbitTemplate, times(1)).convertAndSend(eq(event.routingKey()), notifyUpdateMessage.capture());
assertThat(notifyUpdateMessage.getValue().getPayload().getOfficialsGroupManagerId()).isNull();
}
}
......@@ -29,7 +29,7 @@ class OfficeGwListenerTest extends OfficialsAppTestBase {
final OfficesResponse response = listener.getOffices(request);
Assertions.assertThat(response.getPayload().size()).isEqualTo(16);
Assertions.assertThat(response.getPayload()).hasSize(16);
}
@Test
......
......@@ -29,7 +29,7 @@ class OfficeMsListenerTest extends OfficialsAppTestBase {
OfficesMsResponse response = listener.getOffices(request);
Assertions.assertThat(response.getPayload().size()).isEqualTo(16);
Assertions.assertThat(response.getPayload()).hasSize(16);
}
@Test
......@@ -45,4 +45,5 @@ class OfficeMsListenerTest extends OfficialsAppTestBase {
Assertions.assertThat(response.getPayload().getId()).isEqualTo(officeId);
}
}
......@@ -147,7 +147,7 @@ class OfficialsListenerTest extends OfficialsAppTestBase {
assertThat(officialsSequenceEntities.stream().allMatch(e -> e.getLastSelectedOfficialId() == null)).isTrue();
OfficialsSequenceEntity officialsSequenceEntity = officialsSequenceRepository.findById(UUID.fromString("4b60bfe3-83a5-4ba0-9495-22beb9f4abbf")).orElse(null);
assertThat(officialsSequenceEntity.getLastSelectedOfficialId().equals(UUID.fromString("3dac227f-a8af-4771-8d8b-01409ac7fef0"))).isTrue();
assertThat(officialsSequenceEntity.getLastSelectedOfficialId()).isEqualTo(UUID.fromString("3dac227f-a8af-4771-8d8b-01409ac7fef0"));
}
@Test
......
......@@ -75,7 +75,7 @@ class CreateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
}
@Test
public void create_officialsSequenceIdMissing_badRequest() {
void create_officialsSequenceIdMissing_badRequest() {
payload.setOfficialsSequenceId(null);
request.setPayload(payload, requestMetaDTO);
......@@ -89,7 +89,7 @@ class CreateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
}
@Test
public void create_officialUserIdMissing_badRequest() {
void create_officialUserIdMissing_badRequest() {
payload.setOfficialUserId(null);
request.setPayload(payload, requestMetaDTO);
......@@ -103,7 +103,7 @@ class CreateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
}
@Test
public void create_sequenceDeleted_notFound() {
void create_sequenceDeleted_notFound() {
payload.setOfficialsSequenceId(DELETED_OFFICIALS_SEQUENCE_ID);
request.setPayload(payload, requestMetaDTO);
......@@ -114,7 +114,7 @@ class CreateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
}
@Test
public void create_officialUserDeleted_notFound() {
void create_officialUserDeleted_notFound() {
payload.setOfficialUserId(DELETED_OFFICIAL_USER_ID);
request.setPayload(payload, requestMetaDTO);
......@@ -125,7 +125,7 @@ class CreateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
}
@Test
public void create_officialUserInSequenceAlreadyExists_returnsExisting_success() {
void create_officialUserInSequenceAlreadyExists_returnsExisting_success() {
payload.setOfficialUserId(UUID.fromString("3dac227f-a8af-4771-8d8b-01409ac7fef0"));
request.setPayload(payload, requestMetaDTO);
......@@ -174,7 +174,7 @@ class CreateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
}
@Test
public void create_activeFalse_success() {
void create_activeFalse_success() {
payload.setActive(FALSE);
request.setPayload(payload, requestMetaDTO);
......
......@@ -58,7 +58,7 @@ class DeleteOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
}
@Test
public void delete_idMissing_badRequest() {
void delete_idMissing_badRequest() {
request.setPayload(null, requestMetaDTO);
DeleteOfficialInSequenceResponse response = listener.delete(request);
......@@ -81,7 +81,7 @@ class DeleteOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
}
@Test
public void delete_sequenceDeleted_success() {
void delete_sequenceDeleted_success() {
request.setPayload(OFFICIAL_IN_SEQUENCE_ID_DELETED_SEQUENCE, requestMetaDTO);
DeleteOfficialInSequenceResponse response = listener.delete(request);
......@@ -108,7 +108,7 @@ class DeleteOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
}
@Test
public void delete_objectStatusDeleted_lastOfficialIsNotNulled_success() {
void delete_objectStatusDeleted_lastOfficialIsNotNulled_success() {
request.setPayload(CURRENT_OFFICIAL_IN_SEQUENCE_ID_2, requestMetaDTO);
DeleteOfficialInSequenceResponse response = listener.delete(request);
......
......@@ -30,13 +30,15 @@ class UpdateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
public static final UUID ACTIVE_OFFICIAL_IN_SEQUENCE_ID_2 = UUID.fromString("724bcfca-cb71-4a9c-ae94-c111a4565610");
public static final UUID INACTIVE_OFFICIAL_IN_SEQUENCE_ID = UUID.fromString("c080f99e-4f82-4f4b-a414-270e4341a82c");
public static final UUID DELETED_OFFICIAL_IN_SEQUENCE_ID = UUID.fromString("4ce470d6-c23d-4277-819f-07f117307486");
UpdateOfficialInSequenceRequest request;
RequestMetaDTO requestMetaDTO;
@Autowired
private OfficialInSequenceGwListener listener;
@Autowired
private OfficialInSequenceDataService dataService;
UpdateOfficialInSequenceRequest request;
RequestMetaDTO requestMetaDTO;
@BeforeEach
void setUp() {
requestMetaDTO = createRequestMeta(randomUUID().toString(), OFFICIAL_USER, randomUUID().toString(), List.of(TI_MANAGE_OFFICIALS_SEQUENCES.name()));
......@@ -55,7 +57,7 @@ class UpdateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
}
@Test
public void update_idMissing_badRequest() {
void update_idMissing_badRequest() {
request.setPayload(new UpdateOfficialInSequenceDto(null, true), requestMetaDTO);
UpdateOfficialInSequenceResponse response = listener.update(request);
......@@ -64,7 +66,7 @@ class UpdateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
}
@Test
public void update_activeMissing_badRequest() {
void update_activeMissing_badRequest() {
request.setPayload(new UpdateOfficialInSequenceDto(randomUUID(), null), requestMetaDTO);
UpdateOfficialInSequenceResponse response = listener.update(request);
......@@ -83,20 +85,18 @@ class UpdateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
}
@Override
@Test
public void update_minimumData_success() {
// not implemented, minimum and full are equal
}
@Override
@Test
public void update_fullData_success() {
// not implemented, implementation is in the following tests
}
@Test
@Transactional
public void update_activeToActive_success() {
void update_activeToActive_success() {
request.setPayload(new UpdateOfficialInSequenceDto(ACTIVE_OFFICIAL_IN_SEQUENCE_ID_1, true), requestMetaDTO);
UpdateOfficialInSequenceResponse response = listener.update(request);
......@@ -106,7 +106,7 @@ class UpdateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
@Test
@Transactional
public void update_activeToInactive_success() {
void update_activeToInactive_success() {
request.setPayload(new UpdateOfficialInSequenceDto(ACTIVE_OFFICIAL_IN_SEQUENCE_ID_1, false), requestMetaDTO);
UpdateOfficialInSequenceResponse response = listener.update(request);
......@@ -116,7 +116,7 @@ class UpdateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
@Test
@Transactional
public void update_inactiveToInactive_success() {
void update_inactiveToInactive_success() {
request.setPayload(new UpdateOfficialInSequenceDto(INACTIVE_OFFICIAL_IN_SEQUENCE_ID, false), requestMetaDTO);
UpdateOfficialInSequenceResponse response = listener.update(request);
......@@ -126,7 +126,7 @@ class UpdateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
@Test
@Transactional
public void update_inactiveToActive_success() {
void update_inactiveToActive_success() {
request.setPayload(new UpdateOfficialInSequenceDto(INACTIVE_OFFICIAL_IN_SEQUENCE_ID, true), requestMetaDTO);
UpdateOfficialInSequenceResponse response = listener.update(request);
......
......@@ -43,7 +43,6 @@ class OfficialsSequenceGwListenerTest extends OfficialsAppTestBase implements Li
request.setPayload(null, requestMetaDTO);
}
@Override
@Test
public void getObject_idNotExists_notFound() {
......@@ -56,7 +55,7 @@ class OfficialsSequenceGwListenerTest extends OfficialsAppTestBase implements Li
}
@Test
public void getObject_idMissing_badRequest() {
void getObject_idMissing_badRequest() {
request.setPayload(null, requestMetaDTO);
GetOfficialsSequenceResponse response = listener.getOfficialsSequence(request);
......@@ -122,7 +121,7 @@ class OfficialsSequenceGwListenerTest extends OfficialsAppTestBase implements Li
}
@Test
public void getObject_noRelatedCurrentOfficialUsers_success() {
void getObject_noRelatedCurrentOfficialUsers_success() {
request.setPayload(UUID.fromString("2240f456-0d7c-4e54-bec7-4e57026e8575"), requestMetaDTO);
GetOfficialsSequenceResponse response = listener.getOfficialsSequence(request);
......@@ -137,7 +136,7 @@ class OfficialsSequenceGwListenerTest extends OfficialsAppTestBase implements Li
}
@Test
public void getObject_noRelatedCurrentUsers_success() {
void getObject_noRelatedCurrentUsers_success() {
request.setPayload(UUID.fromString("7730f0e1-89f3-48c3-99da-44fce34b607f"), requestMetaDTO);
GetOfficialsSequenceResponse response = listener.getOfficialsSequence(request);
......@@ -152,7 +151,7 @@ class OfficialsSequenceGwListenerTest extends OfficialsAppTestBase implements Li
}
@Test
public void getObject_oneRelatedCurrentUser_success() {
void getObject_oneRelatedCurrentUser_success() {
request.setPayload(UUID.fromString("25c02b6b-2189-4736-9d61-4f9132c70dd5"), requestMetaDTO);
GetOfficialsSequenceResponse response = listener.getOfficialsSequence(request);
......@@ -194,4 +193,5 @@ class OfficialsSequenceGwListenerTest extends OfficialsAppTestBase implements Li
assertResponseForbidden(response.getError());
}
}
......@@ -44,7 +44,7 @@ class OfficialsSequenceGwTestListenerTest extends OfficialsAppTestBase {
private void assertLastSelectedOfficialIsUpdated(String code, UUID userId) {
OfficialsSequenceEntity sequence = dataService.getCurrentByCode(code);
assertThat(sequence.getLastSelectedOfficialId().equals(userId)).isTrue();
assertThat(sequence.getLastSelectedOfficialId()).isEqualTo(userId);
}
}
......@@ -61,7 +61,6 @@ class OfficialsSequenceMsListenerTest extends OfficialsAppTestBase {
payload = new OfficialsSequence();
}
@Test
void getOfficialFromSequence_codeMissing_badRequest() {
payload.setCode(null);
......@@ -174,7 +173,6 @@ class OfficialsSequenceMsListenerTest extends OfficialsAppTestBase {
assertLastSelectedOfficialIsUpdated("testCodeLastSelectedUserIsNotActiveReturnNextActiveUser", userKolmasId);
}
@Transactional
@Test
void getOfficialFromSequence_lastUserIdIsNotActive_returnFirstActiveUser_success() {
......@@ -202,7 +200,7 @@ class OfficialsSequenceMsListenerTest extends OfficialsAppTestBase {
private void assertLastSelectedOfficialIsUpdated(String code, UUID userId) {
OfficialsSequenceEntity sequence = dataService.getCurrentByCode(code);
assertThat(sequence.getLastSelectedOfficialId().equals(userId)).isTrue();
assertThat(sequence.getLastSelectedOfficialId()).isEqualTo(userId);
}
}
......@@ -14,7 +14,6 @@ import org.springframework.stereotype.Service;
import java.util.List;
import static ee.sm.ti.teis.types.enums.classifier.ClassifierDefinitionCode.EMTAK;
import static java.util.stream.Collectors.toList;
@Service
@RequiredArgsConstructor
......@@ -24,9 +23,9 @@ public class OfficialsGroupEmtakComposeService {
private final ClassifierService classifierService;
private final ClassifierMapper classifierMapper;
public List<OfficialsGroupEmtakDto> composeDtoList(List<OfficialsGroupEmtakEntity> entities, RequestMetaDTO requestMetaDTO) {
return entities.stream().map(e -> composeDto(e, requestMetaDTO))
.collect(toList());
public List<OfficialsGroupEmtakDto> composeDtoList(List<OfficialsGroupEmtakEntity> entities,
RequestMetaDTO requestMetaDTO) {
return entities.stream().map(e -> composeDto(e, requestMetaDTO)).toList();
}
OfficialsGroupEmtakDto composeDto(OfficialsGroupEmtakEntity entity, RequestMetaDTO requestMetaDTO) {
......@@ -46,4 +45,5 @@ public class OfficialsGroupEmtakComposeService {
dto.getEmtak().setId(entity.getEmtak());
return dto;
}
}
......@@ -14,7 +14,6 @@ import java.util.Optional;
import java.util.UUID;
import java.util.stream.StreamSupport;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
@Service
......@@ -24,7 +23,8 @@ public class OfficialsGroupEmtakDataService {
private final OfficialsGroupEmtakRepository repository;
private final OfficialsGroupEmtakComposeService composeService;
public List<OfficialsGroupEmtakEntity> queryGroupEmtakByIdAndEmtakAndObjectStatus(UUID groupId, String emtak, ObjectStatus status) {
public List<OfficialsGroupEmtakEntity> queryGroupEmtakByIdAndEmtakAndObjectStatus(UUID groupId, String emtak,
ObjectStatus status) {
QOfficialsGroupEmtakEntity entity = QOfficialsGroupEmtakEntity.officialsGroupEmtakEntity;
BooleanBuilder where = new BooleanBuilder();
if (groupId != null) {
......@@ -36,10 +36,11 @@ public class OfficialsGroupEmtakDataService {
if (status != null) {
where.and(entity.objectStatus.eq(status));
}
return StreamSupport.stream(repository.findAll(where).spliterator(), false).collect(toList());
return StreamSupport.stream(repository.findAll(where).spliterator(), false).toList();
}
Optional<OfficialsGroupEmtakEntity> getOfficialsGroupEmtakByGroupIdAndClassifierCode(UUID groupId, String emtakClassifierCode) {
Optional<OfficialsGroupEmtakEntity> getOfficialsGroupEmtakByGroupIdAndClassifierCode(UUID groupId,
String emtakClassifierCode) {
QOfficialsGroupEmtakEntity entity = QOfficialsGroupEmtakEntity.officialsGroupEmtakEntity;
BooleanBuilder where = new BooleanBuilder();
where.and(entity.officialsGroup.id.eq(groupId));
......@@ -51,4 +52,5 @@ public class OfficialsGroupEmtakDataService {
return repository.findById(id)
.orElseThrow(() -> new TeisResourceNotFoundException("Officials group EMTAK relation not found.", List.of(id)));
}
}
......@@ -24,7 +24,6 @@ import org.springframework.validation.annotation.Validated;
import javax.transaction.Transactional;
import javax.validation.constraints.NotNull;
import java.util.*;
import java.util.stream.Collectors;
import static ee.sm.ti.teis.types.enums.ObjectStatus.CURRENT;
......@@ -87,15 +86,11 @@ public class OfficialsGroupBusinessService {
}
public List<OfficialsGroupDto> composeDtoFromEntityList(List<OfficialsGroupEntity> entityList) {
return entityList.stream()
.map(this::composeDtoFromEntity)
.collect(Collectors.toList());
return entityList.stream().map(this::composeDtoFromEntity).toList();
}
public List<OfficialsGroup> composeDomainDtoFromEntityList(List<OfficialsGroupEntity> entityList) {
return entityList.stream()
.map(this::composeDomainDtoFromEntity)
.collect(Collectors.toList());
return entityList.stream().map(this::composeDomainDtoFromEntity).toList();
}
public ObjectStatus validateAndAssignDefaultStatus(String objectStatus) {
......@@ -217,4 +212,5 @@ public class OfficialsGroupBusinessService {
return composeDtoFromEntity(entity);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment