Skip to content

Commit

Permalink
fix: SonarQube code smells (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
grigoriev authored Sep 30, 2024
1 parent 8c10ba1 commit 837a95a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mockStatic;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ void testGetEnumOptionById() {

}

@Test
void testGetEnumOptionByValue() {
FieldMetadata fieldMetadata = ConverterTestUtils.getWorkItemCustomField();

assertEquals(new EnumOption(YES_NO_ENUM_ID, YES.left()), ConverterTestUtils.process(YES.left(), fieldMetadata));
assertEquals(new EnumOption(YES_NO_ENUM_ID, NO.left()), ConverterTestUtils.process(NO.left(), fieldMetadata));
}

@Test
void testGetEnumOptionByValueIgnoringSpaces() {
FieldMetadata fieldMetadata = ConverterTestUtils.getWorkItemCustomField();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ void testGetCollectionWithRevision() {

@Test
void testGetGeneralFields() {
IDataService dataService = mock(IDataService.class);
when(trackerService.getDataService()).thenReturn(dataService);
IDataService mockDataService = mock(IDataService.class);
when(trackerService.getDataService()).thenReturn(mockDataService);
IPrototype prototype = mock(IPrototype.class);
when(prototype.getKeyNames()).thenReturn(List.of("key1", "key2", "key3"));
when(dataService.getPrototype(anyString())).thenReturn(prototype);
when(mockDataService.getPrototype(anyString())).thenReturn(prototype);

FieldMetadata metadata1 = FieldMetadata.builder().id("id1").build();
FieldMetadata metadata2 = FieldMetadata.builder().id("id2").build();
Expand All @@ -263,14 +263,14 @@ void testGetGeneralFields() {

@Test
void testGetCustomFields() {
IDataService dataService = mock(IDataService.class);
when(trackerService.getDataService()).thenReturn(dataService);
IDataService mockDataService = mock(IDataService.class);
when(trackerService.getDataService()).thenReturn(mockDataService);
ICustomFieldsService customFieldsService = mock(ICustomFieldsService.class);
ICustomField customField1 = mock(ICustomField.class);
ICustomField customField2 = mock(ICustomField.class);
ICustomField customField3 = mock(ICustomField.class);
when(customFieldsService.getCustomFields(anyString(), any(), anyString())).thenReturn(List.of(customField1, customField2, customField3));
when(dataService.getCustomFieldsService()).thenReturn(customFieldsService);
when(mockDataService.getCustomFieldsService()).thenReturn(customFieldsService);

FieldMetadata metadata1 = FieldMetadata.builder().id("id1").build();
FieldMetadata metadata2 = FieldMetadata.builder().id("id2").build();
Expand Down Expand Up @@ -407,10 +407,10 @@ void testGetOptionsForEnum() {
void testGetEnumeration() {
when(polarionService.getEnumeration(any(), any())).thenCallRealMethod();

IDataService dataService = mock(IDataService.class);
when(trackerService.getDataService()).thenReturn(dataService);
IDataService mockDataService = mock(IDataService.class);
when(trackerService.getDataService()).thenReturn(mockDataService);
IEnumeration enumeration = mock(IEnumeration.class);
when(dataService.getEnumerationForEnumId(any(), any())).thenReturn(enumeration);
when(mockDataService.getEnumerationForEnumId(any(), any())).thenReturn(enumeration);

assertSame(enumeration, polarionService.getEnumeration(mock(IEnumType.class), mock(IContextId.class)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ protected String serializeModelData() {

@Override
protected void deserializeModelData(String serializedString) {

// do nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ public IDataService getDataService() {

@Override
public void resolveAll() {
// do nothing
}

@Override
public void resolveFirst(int i) {
public void resolveFirst(int n) {
// do nothing
}

@Override
public void resolve(int i, int i1) {
public void resolve(int first, int length) {
// do nothing
}

@Override
Expand Down

0 comments on commit 837a95a

Please sign in to comment.