use of com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake in project Backend by FredBoat.
the class PrefixControllerTest method testDeleteSingle.
// test remove single prefix
@WithMockUser(roles = "ADMIN")
@Test
public void testDeleteSingle() throws Exception {
DiscordSnowflake guildId = generateUniqueSnowflakeId();
DiscordSnowflake botId = generateUniqueSnowflakeId();
String[] removePrefix = { ";;" };
this.mockMvc.perform(delete(urlTemplate, guildId, botId).content(this.gson.toJson(removePrefix)).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("!"))).andExpect(jsonPath("$.prefixes.length()", is(Prefix.DEFAULT_PREFIXES.size() - 1)));
}
use of com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake in project Backend by FredBoat.
the class PrefixControllerTest method testAddMultiple.
// test add multiple prefixes
@WithMockUser(roles = "ADMIN")
@Test
public void testAddMultiple() throws Exception {
DiscordSnowflake guildId = generateUniqueSnowflakeId();
DiscordSnowflake botId = generateUniqueSnowflakeId();
String[] addPrefixes = { "this_is_a_prefix", "this_is_another_one" };
this.mockMvc.perform(post(urlTemplate, guildId, botId).content(this.gson.toJson(addPrefixes)).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", hasItems(addPrefixes))).andExpect(jsonPath("$.prefixes.length()", is(Prefix.DEFAULT_PREFIXES.size() + addPrefixes.length)));
}
Aggregations