|
| 1 | +package com.axway.apim.model; |
| 2 | + |
| 3 | +import java.io.IOException; |
| 4 | + |
| 5 | +import org.testng.Assert; |
| 6 | +import org.testng.annotations.Test; |
| 7 | + |
| 8 | +import com.axway.apim.api.API; |
| 9 | +import com.axway.apim.api.APIBaseDefinition; |
| 10 | +import com.fasterxml.jackson.core.JsonParseException; |
| 11 | +import com.fasterxml.jackson.databind.JsonMappingException; |
| 12 | +import com.fasterxml.jackson.databind.JsonNode; |
| 13 | +import com.fasterxml.jackson.databind.ObjectMapper; |
| 14 | + |
| 15 | +public class BEAPICreatedResponseTest { |
| 16 | + |
| 17 | + private static final String testPackage = "com/axway/apim/model/"; |
| 18 | + |
| 19 | + ObjectMapper mapper = new ObjectMapper(); |
| 20 | + |
| 21 | + @Test |
| 22 | + public void parseResponseHavingCreatedOn() throws JsonParseException, JsonMappingException, IOException { |
| 23 | + JsonNode jsonNode = mapper.readTree(this.getClass().getClassLoader().getResourceAsStream(testPackage + "BEAPICreatedWithCreatedOn.json")); |
| 24 | + API createdAPI = new APIBaseDefinition(); |
| 25 | + createdAPI.setApiId(jsonNode.get("id").asText()); |
| 26 | + createdAPI.setName(jsonNode.get("name").asText()); |
| 27 | + createdAPI.setName(jsonNode.get("description").asText()); |
| 28 | + |
| 29 | + createdAPI.setCreatedOn(Long.parseLong(jsonNode.get("createdOn").asText())); |
| 30 | + |
| 31 | + Assert.assertEquals(new Long("1605099396581"), createdAPI.getCreatedOn()); |
| 32 | + // Tests if the Unicode-Description is parsed without giving a encoding |
| 33 | + Assert.assertEquals("提供銀行身份認證整合 Axway APIM OAuth Authorization Code Grant Flow\n", jsonNode.get("description").asText()); |
| 34 | + } |
| 35 | +} |
0 commit comments