Skip to content

Commit

Permalink
[JENKINS-73845] Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dohbedoh committed Oct 24, 2024
1 parent e1404a4 commit d6152fd
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDate;
import java.util.Random;
import java.util.stream.Stream;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.junit.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand Down Expand Up @@ -210,6 +214,18 @@ public void testReadOperatingSystemNames(String fileName, String pattern, String
assertThat(monitor.readOperatingSystemName(releaseFile, pattern), is(job));
}

@Test
public void testReadOperatingSystemListOnWarningDate() throws Exception {
JSONObject eolIn6Months = new JSONObject();
eolIn6Months.put("pattern", ".*");
eolIn6Months.put("endOfLife", LocalDate.now().plusMonths(6).toString());
JSONArray jsonArray = new JSONArray();
jsonArray.add(eolIn6Months);
monitor.readOperatingSystemList(jsonArray.toString());
assertTrue(monitor.isActivated());
assertEquals(LocalDate.now().plusMonths(6).toString(), monitor.getEndOfLifeDate());
}

@Test
public void testReadOperatingSystemNameMissingFile() {
assertThat(monitor.readOperatingSystemName(new File("/this/file/does/not/exist"), ".*"), is(""));
Expand Down

0 comments on commit d6152fd

Please sign in to comment.