Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

fixed sonar issues #1996

Merged
merged 8 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,19 @@ void testRetentionThresholdRejectsNegativeValue(int daysToRetain) {
@Test
void testSetTransmissionRiskLevel() {
diagnosisKey.setTransmissionRiskLevel(0);
assertThat(diagnosisKey.getTransmissionRiskLevel()).isEqualTo(0);
}

@Test
void testSetReportType() {
diagnosisKey.setReportType(null);
assertThat(diagnosisKey.getReportType()).isEqualTo(null);
}

@Test
void testSetDaysSinceOnsetOfSymptoms() {
diagnosisKey.setDaysSinceOnsetOfSymptoms(0);
assertThat(diagnosisKey.getDaysSinceOnsetOfSymptoms()).isEqualTo(0);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app.coronawarn.server.services.distribution.assembly.component;

import static java.util.Collections.emptyList;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyMap;
import static org.mockito.Mockito.doThrow;
Expand Down Expand Up @@ -54,24 +55,33 @@ class DccRevocationListStructureProviderExceptionTests {
void coverFetchDccRevocationListFetchDccListException() throws Exception {
doThrow(FetchDccListException.class).when(dccRevocationClient).getETag();
underTest.fetchDccRevocationList();
assertThatThrownBy(() -> dccRevocationClient.getETag())
.isExactlyInstanceOf(FetchDccListException.class);
}

@Test
void coverProtobufMappingChunkList() throws Exception {
doThrow(RuntimeException.class).when(dccRevocationListToProtobufMapping)
.constructProtobufMappingChunkList(anyList());
underTest.getDccRevocationKidTypeChunk(emptyList());
assertThatThrownBy(() -> dccRevocationListToProtobufMapping.constructProtobufMappingChunkList(anyList()))
.isExactlyInstanceOf(RuntimeException.class);

}

@Test
void coverProtobufMappingKidList() throws Exception {
doThrow(RuntimeException.class).when(dccRevocationListToProtobufMapping).constructProtobufMappingKidList(anyMap());
underTest.getDccRevocationDirectory();
assertThatThrownBy(() -> dccRevocationListToProtobufMapping.constructProtobufMappingKidList(anyMap()))
.isExactlyInstanceOf(RuntimeException.class);
}

@Test
void coverProtobufMappingKidType() throws Exception {
doThrow(RuntimeException.class).when(dccRevocationListToProtobufMapping).constructProtobufMappingKidType(anyList());
underTest.getDccRevocationKidTypeArchive(emptyList());
assertThatThrownBy(() -> dccRevocationListToProtobufMapping.constructProtobufMappingKidType(anyList()))
.isExactlyInstanceOf(RuntimeException.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package app.coronawarn.server.services.distribution.assembly.component;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;

import app.coronawarn.server.common.persistence.domain.RevocationEntry;
import app.coronawarn.server.common.persistence.domain.RevocationEtag;
import app.coronawarn.server.common.persistence.service.DccRevocationListService;
import app.coronawarn.server.common.shared.collection.ImmutableStack;
import app.coronawarn.server.services.distribution.assembly.structure.Writable;
Expand All @@ -17,19 +20,22 @@
import app.coronawarn.server.services.distribution.assembly.structure.directory.DirectoryOnDisk;
import app.coronawarn.server.services.distribution.config.DistributionServiceConfig;
import app.coronawarn.server.services.distribution.dcc.DccRevocationListToProtobufMapping;
import app.coronawarn.server.services.distribution.dcc.FetchDccListException;
import app.coronawarn.server.services.distribution.dcc.TestDccRevocationClient;
import app.coronawarn.server.services.distribution.dcc.decode.DccRevocationListDecoder;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.Rule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.rules.TemporaryFolder;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer;
Expand Down Expand Up @@ -145,11 +151,17 @@ void shouldCreateCorrectFileStructureFromEmptyDbList() {
@Test
void coverFetchDccRevocationList() {
underTest.fetchDccRevocationList();
//final RevocationEtag etag = new RevocationEtag("chunk", dccRevocationClient.getETag());
//Optional<List<RevocationEntry>> dccRevocationList = dccRevocationClient.getDccRevocationList();
//Mockito.verify(dccRevocationListService, Mockito.times(1)).store(dccRevocationList.get());
//Mockito.verify(dccRevocationListService, Mockito.times(1)).store(etag);
hilmarf marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
void coverFetchDccRevocationListException() throws Exception {
doThrow(RuntimeException.class).when(dccRevocationListService).store(anyList());
underTest.fetchDccRevocationList();
assertThatThrownBy(() -> dccRevocationListService.store(anyList()))
.isExactlyInstanceOf(RuntimeException.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package app.coronawarn.server.services.distribution.assembly.component;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import app.coronawarn.server.services.distribution.config.DistributionServiceConfig;
Expand All @@ -25,6 +26,8 @@ public String getOutput() {
void testClear() throws IOException {
OutputDirectoryProvider p = new OutputDirectoryProvider(mockConf);
p.clear();
java.io.File outputDirectory = p.getFileOnDisk();
assertEquals(outputDirectory.listFiles().length, 0);
}

@Test
Expand Down