Search in sources :

Example 16 with DiscordSnowflake

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)));
}
Also used : DiscordSnowflake(com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake) WithMockUser(org.springframework.security.test.context.support.WithMockUser) BaseTest(com.fredboat.backend.quarterdeck.BaseTest) Test(org.junit.jupiter.api.Test)

Example 17 with DiscordSnowflake

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)));
}
Also used : DiscordSnowflake(com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake) WithMockUser(org.springframework.security.test.context.support.WithMockUser) BaseTest(com.fredboat.backend.quarterdeck.BaseTest) Test(org.junit.jupiter.api.Test)

Aggregations

DiscordSnowflake (com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake)17 BaseTest (com.fredboat.backend.quarterdeck.BaseTest)16 Test (org.junit.jupiter.api.Test)16 WithMockUser (org.springframework.security.test.context.support.WithMockUser)16 HashMap (java.util.HashMap)6 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)6 GuildPlayer (com.fredboat.backend.quarterdeck.db.entities.main.GuildPlayer)1 Prefix (com.fredboat.backend.quarterdeck.db.entities.main.Prefix)1 GuildPlayerRepo (com.fredboat.backend.quarterdeck.db.repositories.api.GuildPlayerRepo)1 PatchParseUtil (com.fredboat.backend.quarterdeck.parsing.PatchParseUtil)1 RepeatModeParseException (com.fredboat.backend.quarterdeck.parsing.RepeatModeParseException)1 RepeatMode (fredboat.definitions.RepeatMode)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Function (java.util.function.Function)1 Component (org.springframework.stereotype.Component)1 DatabaseWrapper (space.npstr.sqlsauce.DatabaseWrapper)1