use of com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake in project Backend by FredBoat.
the class GuildDataControllerTest method testPatch.
@WithMockUser(roles = "ADMIN")
@Test
public void testPatch() throws Exception {
Map<String, Object> patchGuildData = new HashMap<>();
long now = System.currentTimeMillis();
patchGuildData.put("helloSent", now);
DiscordSnowflake guildId = generateUniqueSnowflakeId();
MockHttpServletRequestBuilder request = patch(urlTemplate, guildId).content(this.gson.toJson(patchGuildData)).contentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
this.mockMvc.perform(request).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", both(isA(String.class)).and(is(Long.toString(now))))).andDo(document("guild/data/patch"));
}
use of com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake in project Backend by FredBoat.
the class GuildPlayerControllerTest 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("$.voiceChannelId", isA(String.class))).andExpect(jsonPath("$.activeTextChannelId", isA(String.class))).andExpect(jsonPath("$.isPaused", isA(Boolean.class))).andExpect(jsonPath("$.volume", isA(Integer.class))).andExpect(jsonPath("$.repeatMode", isA(String.class))).andExpect(jsonPath("$.isShuffled", isA(Boolean.class))).andDo(document("guild/player/get"));
}
use of com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake in project Backend by FredBoat.
the class GuildPlayerControllerTest method testPatch.
@WithMockUser(roles = "ADMIN")
@Test
public void testPatch() throws Exception {
Map<String, Object> patchGuildPlayer = new HashMap<>();
patchGuildPlayer.put("voiceChannelId", 42L);
patchGuildPlayer.put("activeTextChannelId", Long.MAX_VALUE);
patchGuildPlayer.put("isPaused", false);
patchGuildPlayer.put("volume", 3);
patchGuildPlayer.put("repeatMode", RepeatMode.ALL);
DiscordSnowflake guildId = generateUniqueSnowflakeId();
MockHttpServletRequestBuilder request = patch(urlTemplate, guildId).content(this.gson.toJson(patchGuildPlayer)).contentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
this.mockMvc.perform(request).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)).andExpect(jsonPath("$.guildId", both(isA(String.class)).and(is(guildId.getSnowflakeId())))).andExpect(jsonPath("$.voiceChannelId", both(isA(String.class)).and(is("42")))).andExpect(jsonPath("$.activeTextChannelId", both(isA(String.class)).and(is(Long.toString(Long.MAX_VALUE))))).andExpect(jsonPath("$.isPaused", both(isA(Boolean.class)).and(is(false)))).andExpect(jsonPath("$.volume", both(isA(Integer.class)).and(is(3)))).andExpect(jsonPath("$.repeatMode", both(isA(String.class)).and(is(equalToIgnoringCase(RepeatMode.ALL.name()))))).andExpect(jsonPath("$.isShuffled", both(isA(Boolean.class)).and(is(false)))).andDo(document("guild/player/patch"));
}
use of com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake in project Backend by FredBoat.
the class GuildPlayerControllerTest method testDelete.
@WithMockUser(roles = "ADMIN")
@Test
public void testDelete() throws Exception {
DiscordSnowflake guildId = generateUniqueSnowflakeId();
this.mockMvc.perform(get(urlTemplate, guildId)).andExpect(jsonPath("$.volume", is(GuildPlayer.DEFAULT_VOLUME)));
Map<String, Object> patchGuildData = new HashMap<>();
patchGuildData.put("volume", 69);
MockHttpServletRequestBuilder patch = patch(urlTemplate, guildId).content(this.gson.toJson(patchGuildData)).contentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
this.mockMvc.perform(patch).andExpect(jsonPath("$.volume", is(69)));
this.mockMvc.perform(get(urlTemplate, guildId)).andExpect(jsonPath("$.volume", is(69)));
this.mockMvc.perform(delete(urlTemplate, guildId)).andExpect(status().isOk()).andDo(document("guild/player/delete"));
this.mockMvc.perform(get(urlTemplate, guildId)).andExpect(jsonPath("$.volume", is(GuildPlayer.DEFAULT_VOLUME)));
}
use of com.fredboat.backend.quarterdeck.rest.v1.transfer.DiscordSnowflake in project Backend by FredBoat.
the class PrefixControllerTest method testGet.
// get
@WithMockUser(roles = "ADMIN")
@Test
public void testGet() throws Exception {
DiscordSnowflake guildId = generateUniqueSnowflakeId();
DiscordSnowflake botId = generateUniqueSnowflakeId();
this.mockMvc.perform(get(urlTemplate, guildId, botId)).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