use of com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake in project Backend by FredBoat.
the class GuildConfigControllerTest method testDelete.
@WithMockUser(roles = "ADMIN")
@Test
public void testDelete() throws Exception {
DiscordSnowflake guildId = generateUniqueSnowflakeId();
this.mockMvc.perform(get(urlTemplate, guildId)).andExpect(jsonPath("$.language", is(equalToIgnoringCase(GuildConfig.DEFAULT_LANGAUGE.getCode()))));
Map<String, Object> patchGuildConfig = new HashMap<>();
patchGuildConfig.put("language", Language.DE_DE.getCode());
MockHttpServletRequestBuilder patch = patch(urlTemplate, guildId).content(this.gson.toJson(patchGuildConfig)).contentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
this.mockMvc.perform(patch).andExpect(jsonPath("$.language", is(equalToIgnoringCase(Language.DE_DE.getCode()))));
this.mockMvc.perform(get(urlTemplate, guildId)).andExpect(jsonPath("$.language", is(equalToIgnoringCase(Language.DE_DE.getCode()))));
this.mockMvc.perform(delete(urlTemplate, guildId)).andExpect(status().isOk()).andDo(document("guild/config/delete"));
this.mockMvc.perform(get(urlTemplate, guildId)).andExpect(jsonPath("$.language", is(equalToIgnoringCase(GuildConfig.DEFAULT_LANGAUGE.getCode()))));
}
use of com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake in project Backend by FredBoat.
the class GuildDataControllerTest method testGet.
@WithMockUser(roles = "ADMIN")
@Test
public void testGet() throws Exception {
DiscordSnowflake guildId = generateUniqueSnowflakeId();
this.mockMvc.perform(get(urlTemplate, guildId)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.guildId", both(isA(String.class)).and(is(guildId.getSnowflakeId())))).andExpect(jsonPath("$.helloSent", isA(String.class))).andDo(document("guild/data/get"));
}
use of com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake in project Backend by FredBoat.
the class GuildDataControllerTest method testDelete.
@WithMockUser(roles = "ADMIN")
@Test
public void testDelete() throws Exception {
DiscordSnowflake guildId = generateUniqueSnowflakeId();
this.mockMvc.perform(get(urlTemplate, guildId)).andExpect(jsonPath("$.helloSent", is(Long.toString(GuildData.DEFAULT_HELLO_SENT_TIMESTAMP))));
Map<String, Object> patchGuildData = new HashMap<>();
long now = System.currentTimeMillis();
patchGuildData.put("helloSent", now);
MockHttpServletRequestBuilder patch = patch(urlTemplate, guildId).content(this.gson.toJson(patchGuildData)).contentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
this.mockMvc.perform(patch).andExpect(jsonPath("$.helloSent", is(Long.toString(now))));
this.mockMvc.perform(get(urlTemplate, guildId)).andExpect(jsonPath("$.helloSent", is(Long.toString(now))));
this.mockMvc.perform(delete(urlTemplate, guildId)).andExpect(status().isOk()).andDo(document("guild/data/delete"));
this.mockMvc.perform(get(urlTemplate, guildId)).andExpect(jsonPath("$.helloSent", is(Long.toString(GuildData.DEFAULT_HELLO_SENT_TIMESTAMP))));
}
use of com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake in project Backend by FredBoat.
the class PrefixControllerTest method testDelete.
// delete
@WithMockUser(roles = "ADMIN")
@Test
public void testDelete() throws Exception {
DiscordSnowflake guildId = generateUniqueSnowflakeId();
DiscordSnowflake botId = generateUniqueSnowflakeId();
this.mockMvc.perform(delete(urlTemplate, guildId, botId).contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.guildId", both(isA(String.class)).and(is(guildId.getSnowflakeId())))).andExpect(jsonPath("$.botId", both(isA(String.class)).and(is(botId.getSnowflakeId())))).andExpect(jsonPath("$.prefixes", hasItems(Prefix.DEFAULT_PREFIXES.toArray(new String[0])))).andExpect(jsonPath("$.prefixes.length()", is(Prefix.DEFAULT_PREFIXES.size())));
}
use of com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake in project Backend by FredBoat.
the class PrefixControllerTest method testDeleteAll.
// test remove all prefixes
@WithMockUser(roles = "ADMIN")
@Test
public void testDeleteAll() throws Exception {
DiscordSnowflake guildId = generateUniqueSnowflakeId();
DiscordSnowflake botId = generateUniqueSnowflakeId();
String[] current = this.gson.fromJson(this.mockMvc.perform(get(urlTemplate, guildId, botId)).andReturn().getResponse().getContentAsString(), com.fredboat.backend.quarterdeck.rest.v1.transfer.Prefix.class).getPrefixes();
this.mockMvc.perform(delete(urlTemplate, guildId, botId).content(this.gson.toJson(current)).contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.guildId", both(isA(String.class)).and(is(guildId.getSnowflakeId())))).andExpect(jsonPath("$.botId", both(isA(String.class)).and(is(botId.getSnowflakeId())))).andExpect(jsonPath("$.prefixes", hasItems(Prefix.DEFAULT_PREFIXES.toArray(new String[0])))).andExpect(jsonPath("$.prefixes.length()", is(Prefix.DEFAULT_PREFIXES.size())));
}
Aggregations