use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class LabelControllerIntegrationTest method testUpdateLabelWithUnexistingLang.
@Test
public void testUpdateLabelWithUnexistingLang() throws Exception {
String code = "THIS_LABEL_HAS_NO_NAME";
ObjectMapper mapper = new ObjectMapper();
try {
assertThat(this.ii18nManager.getLabelGroup(code), is(nullValue()));
ApsProperties labels = new ApsProperties();
labels.put(this.langManager.getDefaultLang().getCode(), "hello");
this.ii18nManager.addLabelGroup(code, labels);
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
LabelRequest request = new LabelRequest();
request.setKey(code);
Map<String, String> languages = new HashMap<>();
languages.put(langManager.getDefaultLang().getCode(), "hello");
languages.put("kk", "hello");
request.setTitles(languages);
String payLoad = mapper.writeValueAsString(request);
ResultActions result = mockMvc.perform(put("/labels/{code}", code).content(payLoad).contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(status().isBadRequest());
} finally {
this.ii18nManager.deleteLabelGroup(code);
}
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class LabelControllerIntegrationTest method testAddLabelWithInvalidLang.
@Test
public void testAddLabelWithInvalidLang() throws Exception {
String code = "THIS_LABEL_HAS_NO_NAME";
ObjectMapper mapper = new ObjectMapper();
try {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
assertThat(this.ii18nManager.getLabelGroup(code), is(nullValue()));
LabelRequest request = new LabelRequest();
request.setKey(code);
Map<String, String> languages = new HashMap<>();
languages.put(langManager.getDefaultLang().getCode(), "hello");
languages.put("de", "hello");
request.setTitles(languages);
String payLoad = mapper.writeValueAsString(request);
ResultActions result = mockMvc.perform(post("/labels").content(payLoad).contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(status().isBadRequest());
} finally {
this.ii18nManager.deleteLabelGroup(code);
}
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class LabelControllerIntegrationTest method testAddLabelWithoutDefaultLang.
@Test
public void testAddLabelWithoutDefaultLang() throws Exception {
String code = "THIS_LABEL_HAS_NO_NAME";
ObjectMapper mapper = new ObjectMapper();
try {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
assertThat(this.ii18nManager.getLabelGroup(code), is(nullValue()));
LabelRequest request = new LabelRequest();
request.setKey(code);
Map<String, String> languages = new HashMap<>();
languages.put(langManager.getDefaultLang().getCode(), "hello");
languages.put("en", "hello");
languages.put("de", "hello");
languages.put("KK", "hello");
request.setTitles(languages);
String payLoad = mapper.writeValueAsString(request);
ResultActions result = mockMvc.perform(post("/labels").content(payLoad).contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(status().isBadRequest());
} finally {
this.ii18nManager.deleteLabelGroup(code);
}
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class LabelControllerIntegrationTest method testGetLabels2.
@Test
public void testGetLabels2() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(get("/labels").param("direction", FieldSearchFilter.DESC_ORDER).param("filter[0].attribute", "value").param("filter[0].value", "gina").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
result.andExpect(jsonPath("$.payload", hasSize(3)));
}
use of com.agiletec.aps.system.services.user.UserDetails in project entando-core by entando.
the class LabelControllerIntegrationTest method testAddLabelWithMissingDefaultLang.
@Test
public void testAddLabelWithMissingDefaultLang() throws Exception {
String code = "THIS_LABEL_HAS_NO_NAME";
ObjectMapper mapper = new ObjectMapper();
try {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
assertThat(this.ii18nManager.getLabelGroup(code), is(nullValue()));
LabelRequest request = new LabelRequest();
request.setKey(code);
Map<String, String> languages = new HashMap<>();
languages.put("en", "hello");
request.setTitles(languages);
String payLoad = mapper.writeValueAsString(request);
ResultActions result = mockMvc.perform(post("/labels").content(payLoad).contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(status().isBadRequest());
} finally {
this.ii18nManager.deleteLabelGroup(code);
}
}
Aggregations