Skip to content

Commit

Permalink
chore: refactoring tests after migration to generic v7.4.0 to reduce …
Browse files Browse the repository at this point in the history
…code duplication (#50)
  • Loading branch information
grigoriev authored Oct 8, 2024
1 parent 4801aae commit c88e3ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ch.sbb.polarion.extensions</groupId>
<artifactId>ch.sbb.polarion.extension.generic</artifactId>
<version>7.3.1</version>
<version>7.4.0</version>
</parent>

<artifactId>ch.sbb.polarion.extension.excel-importer</artifactId>
Expand Down Expand Up @@ -75,6 +75,14 @@
<version>${apache-poi.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>ch.sbb.polarion.extensions</groupId>
<artifactId>ch.sbb.polarion.extension.generic.app</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package ch.sbb.polarion.extension.excel_importer.settings;

import ch.sbb.polarion.extension.generic.context.CurrentContextConfig;
import ch.sbb.polarion.extension.generic.context.CurrentContextExtension;
import ch.sbb.polarion.extension.generic.exception.ObjectNotFoundException;
import ch.sbb.polarion.extension.generic.rest.model.Context;
import ch.sbb.polarion.extension.generic.settings.GenericNamedSettings;
import ch.sbb.polarion.extension.generic.settings.SettingId;
import ch.sbb.polarion.extension.generic.settings.SettingsService;
import ch.sbb.polarion.extension.generic.util.ContextUtils;
import ch.sbb.polarion.extension.generic.util.ScopeUtils;
import com.polarion.subterra.base.location.ILocation;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.junit.jupiter.MockitoExtension;

Expand All @@ -25,23 +21,10 @@
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;

@ExtendWith(MockitoExtension.class)
@ExtendWith({MockitoExtension.class, CurrentContextExtension.class})
@CurrentContextConfig("excel-importer")
class ExcelSheetMappingSettingsTest {

@Mock(answer = Answers.RETURNS_DEEP_STUBS)
MockedStatic<ContextUtils> contextUtils;

@BeforeEach
void setUp() {
Context context = new Context("excel-importer");
contextUtils.when(ContextUtils::getContext).thenReturn(context);
}

@AfterEach
void tearDown() {
contextUtils.close();
}

@Test
void testSettingDoesNotExist() {
try (MockedStatic<ScopeUtils> mockScopeUtils = mockStatic(ScopeUtils.class)) {
Expand Down

0 comments on commit c88e3ac

Please sign in to comment.