Skip to content

Commit

Permalink
chore: remove ExportParams.DocumentType.MIXED from javascript code
Browse files Browse the repository at this point in the history
Refs: #298
  • Loading branch information
grigoriev committed Dec 3, 2024
1 parent 6740e74 commit 44015d5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ public BulkPdfExportWidgetRenderer(@NotNull RichPageWidgetCommonContext context)

}

private @NotNull DocumentType getItemsType(@NotNull PrototypeEnum prototype) {
public @NotNull DocumentType getItemsType(@NotNull PrototypeEnum prototype) {
return switch (prototype) {
case Document -> DocumentType.LIVE_DOC;
case RichPage -> DocumentType.LIVE_REPORT;
case TestRun -> DocumentType.TEST_RUN;
default -> throw new IllegalStateException("Unexpected value: " + prototype);
default -> throw new IllegalArgumentException("Unexpected value: " + prototype);
};
}

private @NotNull String getWidgetItemsType(@NotNull PrototypeEnum prototype) {
public @NotNull String getWidgetItemsType(@NotNull PrototypeEnum prototype) {
return switch (prototype) {
case Document -> "Documents";
case RichPage -> "Pages";
case TestRun -> "Test Runs";
default -> throw new IllegalStateException("Unexpected value: " + prototype);
default -> throw new IllegalArgumentException("Unexpected value: " + prototype);
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package ch.sbb.polarion.extension.pdf_exporter.widgets;

import ch.sbb.polarion.extension.pdf_exporter.rest.model.conversion.DocumentType;
import com.polarion.alm.shared.api.model.PrototypeEnum;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

class BulkPdfExportWidgetRendererTest {

@Test
void testGetItemsType() {
BulkPdfExportWidgetRenderer bulkPdfExportWidgetRenderer = mock(BulkPdfExportWidgetRenderer.class);
when(bulkPdfExportWidgetRenderer.getItemsType(any())).thenCallRealMethod();

assertEquals(DocumentType.LIVE_DOC, bulkPdfExportWidgetRenderer.getItemsType(PrototypeEnum.Document));
assertEquals(DocumentType.LIVE_REPORT, bulkPdfExportWidgetRenderer.getItemsType(PrototypeEnum.RichPage));
assertEquals(DocumentType.TEST_RUN, bulkPdfExportWidgetRenderer.getItemsType(PrototypeEnum.TestRun));
assertThrows(IllegalArgumentException.class, () -> bulkPdfExportWidgetRenderer.getItemsType(PrototypeEnum.WorkItem));
}

@Test
void testGetWidgetItemsType() {
BulkPdfExportWidgetRenderer bulkPdfExportWidgetRenderer = mock(BulkPdfExportWidgetRenderer.class);
when(bulkPdfExportWidgetRenderer.getWidgetItemsType(any())).thenCallRealMethod();

assertEquals("Documents", bulkPdfExportWidgetRenderer.getWidgetItemsType(PrototypeEnum.Document));
assertEquals("Pages", bulkPdfExportWidgetRenderer.getWidgetItemsType(PrototypeEnum.RichPage));
assertEquals("Test Runs", bulkPdfExportWidgetRenderer.getWidgetItemsType(PrototypeEnum.TestRun));
assertThrows(IllegalArgumentException.class, () -> bulkPdfExportWidgetRenderer.getWidgetItemsType(PrototypeEnum.WorkItem));
}
}

0 comments on commit 44015d5

Please sign in to comment.