本文整理了Java中io.kaif.model.zone.Zone.valueOf()
方法的一些代码示例,展示了Zone.valueOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Zone.valueOf()
方法的具体详情如下:
包路径:io.kaif.model.zone.Zone
类名称:Zone
方法名:valueOf
暂无
代码示例来源:origin: kaif-open/kaif
@Override
public Zone deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
String value = jp.readValueAs(String.class);
return Zone.valueOf(value);
}
}
代码示例来源:origin: kaif-open/kaif
@RequestMapping(value = "/external-link", method = RequestMethod.GET)
public List<FlakeId> listArticleIdsByExternalLink(@RequestParam("zone") String rawZone,
@RequestParam("url") String url) {
return articleService.listArticlesByExternalLink(Zone.valueOf(rawZone), url)
.stream()
.map(Article::getArticleId)
.collect(toList());
}
代码示例来源:origin: kaif-open/kaif
@ApiOperation(value = "[public] check url already submitted in zone",
notes = "Check url already submitted as external-url-article in zone")
@RequiredScope(ClientAppScope.PUBLIC)
@RequestMapping(value = "/zone/{zone}/external-link/exist", method = RequestMethod.GET)
public boolean isExternalLinkExist(ClientAppUserAccessToken accessToken,
@PathVariable(value = "zone") String zone,
@RequestParam("url") String url) {
return articleService.isExternalLinkExist(Zone.valueOf(zone), url);
}
代码示例来源:origin: kaif-open/kaif
@RequestMapping(value = "/external-link/exist", method = RequestMethod.GET)
public SingleWrapper<Boolean> isExternalUrlExist(@RequestParam("zone") String rawZone,
@RequestParam("url") String url) {
return SingleWrapper.of(articleService.isExternalLinkExist(Zone.valueOf(rawZone), url));
}
代码示例来源:origin: kaif-open/kaif
@ApiOperation(value = "[public] List administrators of the zone", notes = "List username of administrators of the zone")
@RequiredScope(PUBLIC)
@RequestMapping(value = "/{zone}/administrator/username", method = RequestMethod.GET)
public List<String> listAdministrators(ClientAppUserAccessToken token,
@PathVariable("zone") String zone) {
return zoneService.listAdministratorsWithCache(Zone.valueOf(zone));
}
}
代码示例来源:origin: kaif-open/kaif
@RequestMapping(value = "/can-create", method = RequestMethod.GET)
public SingleWrapper<Boolean> canCreateArticle(AccountAccessToken token,
@RequestParam("zone") String rawZone) {
return SingleWrapper.of(articleService.canCreateArticle(Zone.valueOf(rawZone), token));
}
代码示例来源:origin: kaif-open/kaif
@ApiOperation(value = "[public] List latest debates for a zone",
notes = "List latest debates for a zone, 25 debates a page. "
+ "To retrieve next page, passing last debate id of previous page in parameter start-debate-id")
@RequiredScope(ClientAppScope.PUBLIC)
@RequestMapping(value = "/zone/{zone}/latest", method = RequestMethod.GET)
public List<V1DebateDto> latestByZone(ClientAppUserAccessToken accessToken,
@PathVariable("zone") String zone,
@RequestParam(value = "start-debate-id", required = false) FlakeId startDebateId) {
return toDtos(articleService.listLatestZoneDebates(Zone.valueOf(zone), startDebateId));
}
代码示例来源:origin: kaif-open/kaif
@ApiOperation(value = "[public] List hot articles for the zone",
notes = "List hot articles for the zone, 25 articles a page. "
+ "To retrieve next page, passing last article id of previous page in parameter start-article-id")
@RequiredScope(ClientAppScope.PUBLIC)
@RequestMapping(value = "/zone/{zone}/hot", method = RequestMethod.GET)
public List<V1ArticleDto> hotByZone(ClientAppUserAccessToken accessToken,
@PathVariable("zone") String zone,
@RequestParam(value = "start-article-id", required = false) FlakeId startArticleId) {
return toDtos(articleService.listHotZoneArticles(Zone.valueOf(zone), startArticleId));
}
代码示例来源:origin: kaif-open/kaif
@ApiOperation(value = "[public] List articles for external link",
notes = "List most 3 external-url-articles for a specific url."
+ "You are encouraged to show exist articles to end user before creating the article "
+ "to prevent article duplication in zone.")
@RequiredScope(ClientAppScope.PUBLIC)
@RequestMapping(value = "/zone/{zone}/external-link", method = RequestMethod.GET)
public List<V1ArticleDto> externalLink(ClientAppUserAccessToken accessToken,
@PathVariable(value = "zone") String zone,
@RequestParam("url") String url) {
return toDtos(articleService.listArticlesByExternalLink(Zone.valueOf(zone), url));
}
代码示例来源:origin: kaif-open/kaif
@Override
public boolean isZoneAvailable(String zone) {
return Zone.isValid(zone) && ZoneInfo.isValidDefault(zone) && !zoneDao.findZoneWithoutCache(Zone
.valueOf(zone)).isPresent();
}
代码示例来源:origin: kaif-open/kaif
private void assertInvalidZone(String rawValue) {
try {
Zone.valueOf(rawValue);
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException expected) {
}
}
}
代码示例来源:origin: kaif-open/kaif
@Test
public void json() throws Exception {
ObjectMapper mapper = new ObjectMapper();
assertEquals("\"abc\"", mapper.writeValueAsString(Zone.valueOf("abc")));
assertEquals(Zone.valueOf("foo"), mapper.readValue("\"foo\"", Zone.class));
assertNull(mapper.readValue("null", Zone.class));
assertEquals("{\"zone\":\"xyz\"}", mapper.writeValueAsString(new FooPojo(Zone.valueOf("xyz"))));
assertEquals(Zone.valueOf("xyz"), mapper.readValue("{\"zone\":\"xyz\"}", FooPojo.class).zone);
}
代码示例来源:origin: kaif-open/kaif
@Test
public void getZone_cached() throws Exception {
service.createDefault("def", "dddd");
ZoneInfo cached = service.loadZone(Zone.valueOf("def"));
assertSame(cached, service.loadZone(Zone.valueOf("def")));
}
代码示例来源:origin: kaif-open/kaif
@Test
public void userHonors() throws Exception {
HonorRoll h1 = honorRoll(zone);
HonorRoll h2 = honorRoll(Zone.valueOf("java"));
when(honorRollService.listHonorAllByUsername("foo-user")).thenReturn(asList(h1, h2));
mockMvc.perform(get("/u/foo-user/honors"))
.andExpect(content().string(containsString("/z/java")));
}
代码示例来源:origin: kaif-open/kaif
@Test
public void listAdministrators() throws Exception {
when(zoneService.listAdministratorsWithCache(Zone.valueOf("foo"))).thenReturn(asList("admin1",
"admin2"));
oauthPerform(user, get("/v1/zone/foo/administrator/username")).andExpect(status().isOk())
.andExpect(jsonPath("$.data[0]", is("admin1")))
.andExpect(jsonPath("$.data[1]", is("admin2")));
}
}
代码示例来源:origin: kaif-open/kaif
@Test
public void redirectDebate() throws Exception {
FlakeId flakeId = FlakeId.fromString("foobar123");
Article article = article(Zone.valueOf("programming"), flakeId, "my article title");
Debate debate = debate(article, "my reply", null);
when(articleService.findArticle(flakeId)).thenReturn(Optional.empty());
when(articleService.loadDebateWithCache(flakeId)).thenReturn(debate);
mockMvc.perform(get("/d/foobar123"))
.andExpect(redirectedUrl("/z/programming/debates/foobar123/" + debate.getDebateId()))
.andExpect(status().isPermanentRedirect());
}
代码示例来源:origin: kaif-open/kaif
@Test
public void listAdministrators() {
Zone zone = Zone.valueOf("foo");
assertTrue(service.listAdministratorsWithCache(zone).isEmpty());
accountDao.changeTotalVotedDebate(citizen.getAccountId(), 30, 0);
service.createByUser("foo", "this is aaa2", citizen);
List<String> administerNames = service.listAdministratorsWithCache(zone);
assertEquals(asList(citizen.getUsername()), administerNames);
}
}
代码示例来源:origin: kaif-open/kaif
@Test
public void redirectArticle() throws Exception {
FlakeId flakeId = FlakeId.fromString("foobar123");
Article article = article(Zone.valueOf("sysop"), flakeId, "my article title");
when(articleService.findArticle(flakeId)).thenReturn(Optional.of(article));
mockMvc.perform(get("/d/foobar123"))
.andExpect(redirectedUrl("/z/sysop/debates/foobar123"))
.andExpect(status().isPermanentRedirect());
}
代码示例来源:origin: kaif-open/kaif
@Test
public void notExistZone_404() throws Exception {
when(zoneService.loadZone(Zone.valueOf("not-exist"))).thenThrow(new EmptyResultDataAccessException(
"fake",
1));
mockMvc.perform(get("/z/not-exist"))
.andExpect(status().isNotFound())
.andExpect(view().name("error"))
.andExpect(content().string(containsString("404")));
}
代码示例来源:origin: kaif-open/kaif
@Test
public void getShortUrlPath() throws Exception {
assertEquals("/d/xyz1234",
article(zone, FlakeId.fromString("xyz1234"), "foo title").getShortUrlPath());
assertEquals("/d/cuteCate",
article(Zone.valueOf("funny"),
FlakeId.fromString("cuteCate"),
"foo title").getShortUrlPath());
}
内容来源于网络,如有侵权,请联系作者删除!