PrefixController { @ApiImplicitParams({ @ApiImplicitParam(name = "guild_id", dataTypeClass = DiscordSnowflake.class, example = "174820236481134592", required = true, paramType = "path", type = "string", format = "Discord snowflake", value = "Discord snowflake"), @ApiImplicitParam(name = "bot_id", dataTypeClass = DiscordSnowflake.class, example = "223809720098488320", required = true, paramType = "query", type = "string", format = "Discord snowflake", value = "Discord snowflake"), }) @GetMapping public Prefix getPrefixes(@PathVariable("guild_id") DiscordSnowflake guildId, @RequestParam("bot_id") DiscordSnowflake botId) { return Prefix.of(this.prefixRepo.fetch(new GuildBotId(guildId.longValue(), botId.longValue()))); } PrefixController(PrefixRepo prefixRepo); @ApiImplicitParams({ @ApiImplicitParam(name = "guild_id", dataTypeClass = DiscordSnowflake.class, example = "174820236481134592", required = true, paramType = "path", type = "string", format = "Discord snowflake", value = "Discord snowflake"), @ApiImplicitParam(name = "bot_id", dataTypeClass = DiscordSnowflake.class, example = "223809720098488320", required = true, paramType = "query", type = "string", format = "Discord snowflake", value = "Discord snowflake"), }) @GetMapping Prefix getPrefixes(@PathVariable("guild_id") DiscordSnowflake guildId,
                              @RequestParam("bot_id") DiscordSnowflake botId); @ApiImplicitParams({ @ApiImplicitParam(name = "guild_id", dataTypeClass = DiscordSnowflake.class, example = "174820236481134592", required = true, paramType = "path", type = "string", format = "Discord snowflake", value = "Discord snowflake"), @ApiImplicitParam(name = "bot_id", dataTypeClass = DiscordSnowflake.class, example = "223809720098488320", required = true, paramType = "query", type = "string", format = "Discord snowflake", value = "Discord snowflake"), @ApiImplicitParam(name = "prefixes", example = "[\";;\", \"!\"]", required = true, paramType = "body", type = "string", format = "string", allowMultiple = true, value = "Array of prefixes. A prefix can be any string."), }) @PostMapping Prefix addPrefixes(@PathVariable("guild_id") DiscordSnowflake guildId,
                              @RequestParam("bot_id") DiscordSnowflake botId,
                              @RequestBody String[] prefixes); @ApiImplicitParams({ @ApiImplicitParam(name = "guild_id", dataTypeClass = DiscordSnowflake.class, example = "174820236481134592", required = true, paramType = "path", type = "string", format = "Discord snowflake", value = "Discord snowflake"), @ApiImplicitParam(name = "bot_id", dataTypeClass = DiscordSnowflake.class, example = "223809720098488320", required = true, paramType = "query", type = "string", format = "Discord snowflake", value = "Discord snowflake"), @ApiImplicitParam(name = "prefixes", example = "[\";;\", \"!\"]", required = true, paramType = "body", type = "string", format = "string", allowMultiple = true, allowEmptyValue = true, value = "Array of (existing) prefixes. None or empty array to reset the whole entity"), }) @DeleteMapping Prefix removeOrResetPrefix(@PathVariable("guild_id") DiscordSnowflake guildId,
                                      @RequestParam("bot_id") DiscordSnowflake botId,
                                      @RequestBody(required = false) @Nullable String[] prefixes);  }
@WithMockUser(roles = "ADMIN") @Test public void testDeleteAll() throws Exception { DiscordSnowflake guildId = generateUniqueSnowflakeId(); DiscordSnowflake botId = generateUniqueSnowflakeId(); String[] current = this.mapper.readValue(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.mapper.writeValueAsString(current)) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_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()))); }