@Test public void wrongBinaryTest() { TimestampDTO wrongBinary = new TimestampDTO(new byte[] { 1, 2, 3 }, TimestampType.CONTENT_TIMESTAMP); Exception e = assertThrows(DSSException.class, () -> TimestampTokenConverter.toTimestampToken(wrongBinary)); assertTrue(e.getMessage().contains("Cannot convert a TimestampDTO to TimestampToken class")); }
public static TimestampToken toTimestampToken(TimestampDTO timestampDTO) throws DSSException { Objects.requireNonNull(timestampDTO, "TimestampDTO cannot be null!"); Objects.requireNonNull(timestampDTO.getBinaries(), "TimestampDTO binaries cannot be null!"); Objects.requireNonNull(timestampDTO.getType(), "TimestampDTO type cannot be null!"); try { TimestampToken timestampToken = new TimestampToken(timestampDTO.getBinaries(), timestampDTO.getType()); timestampToken.setCanonicalizationMethod(timestampDTO.getCanonicalizationMethod()); if (timestampDTO.getIncludes() != null) { timestampToken.setTimestampIncludes(toTimestampIncludes(timestampDTO.getIncludes())); } return timestampToken; } catch (TSPException | IOException | CMSException e) { throw new DSSException(String.format("Cannot convert a TimestampDTO to TimestampToken class, reason : '%s'", e.getMessage()), e); } }
TimestampTokenConverter { public static TimestampToken toTimestampToken(TimestampDTO timestampDTO) throws DSSException { Objects.requireNonNull(timestampDTO, "TimestampDTO cannot be null!"); Objects.requireNonNull(timestampDTO.getBinaries(), "TimestampDTO binaries cannot be null!"); Objects.requireNonNull(timestampDTO.getType(), "TimestampDTO type cannot be null!"); try { TimestampToken timestampToken = new TimestampToken(timestampDTO.getBinaries(), timestampDTO.getType()); timestampToken.setCanonicalizationMethod(timestampDTO.getCanonicalizationMethod()); if (timestampDTO.getIncludes() != null) { timestampToken.setTimestampIncludes(toTimestampIncludes(timestampDTO.getIncludes())); } return timestampToken; } catch (TSPException | IOException | CMSException e) { throw new DSSException(String.format("Cannot convert a TimestampDTO to TimestampToken class, reason : '%s'", e.getMessage()), e); } } }
TimestampTokenConverter { public static TimestampToken toTimestampToken(TimestampDTO timestampDTO) throws DSSException { Objects.requireNonNull(timestampDTO, "TimestampDTO cannot be null!"); Objects.requireNonNull(timestampDTO.getBinaries(), "TimestampDTO binaries cannot be null!"); Objects.requireNonNull(timestampDTO.getType(), "TimestampDTO type cannot be null!"); try { TimestampToken timestampToken = new TimestampToken(timestampDTO.getBinaries(), timestampDTO.getType()); timestampToken.setCanonicalizationMethod(timestampDTO.getCanonicalizationMethod()); if (timestampDTO.getIncludes() != null) { timestampToken.setTimestampIncludes(toTimestampIncludes(timestampDTO.getIncludes())); } return timestampToken; } catch (TSPException | IOException | CMSException e) { throw new DSSException(String.format("Cannot convert a TimestampDTO to TimestampToken class, reason : '%s'", e.getMessage()), e); } }  }
TimestampTokenConverter { public static TimestampToken toTimestampToken(TimestampDTO timestampDTO) throws DSSException { Objects.requireNonNull(timestampDTO, "TimestampDTO cannot be null!"); Objects.requireNonNull(timestampDTO.getBinaries(), "TimestampDTO binaries cannot be null!"); Objects.requireNonNull(timestampDTO.getType(), "TimestampDTO type cannot be null!"); try { TimestampToken timestampToken = new TimestampToken(timestampDTO.getBinaries(), timestampDTO.getType()); timestampToken.setCanonicalizationMethod(timestampDTO.getCanonicalizationMethod()); if (timestampDTO.getIncludes() != null) { timestampToken.setTimestampIncludes(toTimestampIncludes(timestampDTO.getIncludes())); } return timestampToken; } catch (TSPException | IOException | CMSException e) { throw new DSSException(String.format("Cannot convert a TimestampDTO to TimestampToken class, reason : '%s'", e.getMessage()), e); } }  static List<TimestampToken> toTimestampTokens(List<TimestampDTO> timestampDTOs); static TimestampToken toTimestampToken(TimestampDTO timestampDTO); static TimestampDTO toTimestampDTO(TimestampToken timestampToken); }
TimestampTokenConverter { public static TimestampToken toTimestampToken(TimestampDTO timestampDTO) throws DSSException { Objects.requireNonNull(timestampDTO, "TimestampDTO cannot be null!"); Objects.requireNonNull(timestampDTO.getBinaries(), "TimestampDTO binaries cannot be null!"); Objects.requireNonNull(timestampDTO.getType(), "TimestampDTO type cannot be null!"); try { TimestampToken timestampToken = new TimestampToken(timestampDTO.getBinaries(), timestampDTO.getType()); timestampToken.setCanonicalizationMethod(timestampDTO.getCanonicalizationMethod()); if (timestampDTO.getIncludes() != null) { timestampToken.setTimestampIncludes(toTimestampIncludes(timestampDTO.getIncludes())); } return timestampToken; } catch (TSPException | IOException | CMSException e) { throw new DSSException(String.format("Cannot convert a TimestampDTO to TimestampToken class, reason : '%s'", e.getMessage()), e); } }  static List<TimestampToken> toTimestampTokens(List<TimestampDTO> timestampDTOs); static TimestampToken toTimestampToken(TimestampDTO timestampDTO); static TimestampDTO toTimestampDTO(TimestampToken timestampToken);  }