-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91b123e
commit 1d64cb7
Showing
2 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
src/main/java/org/zendesk/client/v2/model/hc/ContentTag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package org.zendesk.client.v2.model.hc; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.Date; | ||
import java.util.Objects; | ||
|
||
/** | ||
* You can assign a content tag to posts and articles to loosely group them together. | ||
* </p> | ||
* For more information, see <a href="https://support.zendesk.com/hc/en-us/articles/4848925672730">About Content tags</a> | ||
* in Zendesk help. | ||
*/ | ||
public class ContentTag { | ||
|
||
/** Automatically assigned when the content tag is created. | ||
* N.B. unlike many other entities, the id field is a String, not a Long */ | ||
private String id; | ||
|
||
/** The name of the content tag */ | ||
private String name; | ||
|
||
/** The time the content tag was created */ | ||
@JsonProperty("created_at") | ||
private Date createdAt; | ||
|
||
/** The time the content tag was last updated */ | ||
@JsonProperty("updated_at") | ||
private Date updatedAt; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Date getCreatedAt() { | ||
return createdAt; | ||
} | ||
|
||
public void setCreatedAt(Date createdAt) { | ||
this.createdAt = createdAt; | ||
} | ||
|
||
public Date getUpdatedAt() { | ||
return updatedAt; | ||
} | ||
|
||
public void setUpdatedAt(Date updatedAt) { | ||
this.updatedAt = updatedAt; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ContentTag that = (ContentTag) o; | ||
return Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id, name, createdAt, updatedAt); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ContentTag{" + | ||
"id='" + id + '\'' + | ||
", name='" + name + '\'' + | ||
", createdAt=" + createdAt + | ||
", updatedAt=" + updatedAt + | ||
'}'; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/test/java/org/zendesk/client/v2/model/hc/ContentTagTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.zendesk.client.v2.model.hc; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.Test; | ||
|
||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class ContentTagTest { | ||
|
||
private ContentTag parseJson(byte[] json) { | ||
ObjectMapper mapper = new ObjectMapper(); | ||
try { | ||
return mapper.readValue(json, ContentTag.class); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
|
||
@Test | ||
public void testParsePermissionGroup() throws ParseException { | ||
String json = "{\n" + | ||
" \"created_at\": \"2022-10-13T12:34:56.000Z\",\n" + | ||
" \"id\": \"01GFXGBX7YZ9ASWTCVMASTK8ZS\",\n" + | ||
" \"name\": \"feature request\",\n" + | ||
" \"updated_at\": \"2022-10-13T13:44:55.000Z\"\n" + | ||
"}"; | ||
ContentTag ct = parseJson(json.getBytes()); | ||
|
||
assertNotNull(ct); | ||
assertEquals(ContentTag.class, ct.getClass()); | ||
assertEquals("01GFXGBX7YZ9ASWTCVMASTK8ZS", ct.getId()); | ||
assertEquals("feature request", ct.getName()); | ||
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); | ||
Date created = simpleDateFormat.parse("2022-10-13 12:34:56 +0000"); | ||
assertEquals(created, ct.getCreatedAt()); | ||
Date updated = simpleDateFormat.parse("2022-10-13 13:44:55 +0000"); | ||
assertEquals(updated, ct.getUpdatedAt()); | ||
} | ||
|
||
} |