001/* 002 * acme4j - Java ACME client 003 * 004 * Copyright (C) 2016 Richard "Shred" Körber 005 * http://acme4j.shredzone.org 006 * 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 013 */ 014package org.shredzone.acme4j.exception; 015 016import static org.assertj.core.api.Assertions.assertThat; 017import static org.junit.jupiter.api.Assertions.assertThrows; 018 019import java.time.Duration; 020import java.time.Instant; 021 022import org.junit.jupiter.api.Test; 023 024/** 025 * Unit tests for {@link AcmeRetryAfterException}. 026 */ 027public class AcmeRetryAfterExceptionTest { 028 029 /** 030 * Test that parameters are correctly returned. 031 */ 032 @Test 033 public void testAcmeRetryAfterException() { 034 var detail = "Too early"; 035 var retryAfter = Instant.now().plus(Duration.ofMinutes(1)); 036 037 var ex = new AcmeRetryAfterException(detail, retryAfter); 038 039 assertThat(ex.getMessage()).isEqualTo(detail); 040 assertThat(ex.getRetryAfter()).isEqualTo(retryAfter); 041 } 042 043 /** 044 * Test that date is required. 045 */ 046 @Test 047 public void testRequiredAcmeRetryAfterException() { 048 assertThrows(NullPointerException.class, () -> { 049 throw new AcmeRetryAfterException("null-test", null); 050 }); 051 } 052 053}