use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class CategoryControllerIntegrationTest method testUpdateCategory.
@Test
public void testUpdateCategory() throws Exception {
String categoryCode = "test_cat2";
try {
Assert.assertNotNull(this.categoryManager.getCategory("cat1"));
Assert.assertNull(this.categoryManager.getCategory(categoryCode));
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = this.executePost("2_POST_valid.json", accessToken, status().isOk());
result.andExpect(jsonPath("$.errors", Matchers.hasSize(0)));
result.andExpect(jsonPath("$.payload.code", is(categoryCode)));
result = this.executePut("2_PUT_invalid_1.json", categoryCode, accessToken, status().isBadRequest());
result.andExpect(jsonPath("$.payload", Matchers.hasSize(0)));
result.andExpect(jsonPath("$.errors[0].code", is(CategoryValidator.ERRCODE_PARENT_CATEGORY_CANNOT_BE_CHANGED)));
result = this.executePut("2_PUT_invalid_2.json", categoryCode, accessToken, status().isBadRequest());
result.andExpect(jsonPath("$.payload", Matchers.hasSize(0)));
result.andExpect(jsonPath("$.errors[0].code", is("53")));
result = this.executePut("2_PUT_valid.json", "home", accessToken, status().isBadRequest());
result.andExpect(jsonPath("$.payload", Matchers.hasSize(0)));
result.andExpect(jsonPath("$.errors[0].code", is(CategoryValidator.ERRCODE_URINAME_MISMATCH)));
result = this.executePut("2_PUT_valid.json", categoryCode, accessToken, status().isOk());
result.andExpect(jsonPath("$.errors", Matchers.hasSize(0)));
result.andExpect(jsonPath("$.payload.code", is(categoryCode)));
Category modified = this.categoryManager.getCategory(categoryCode);
Assert.assertNotNull(modified);
Assert.assertTrue(modified.getTitle("en").startsWith("New "));
Assert.assertTrue(modified.getTitle("it").startsWith("Nuovo "));
result = this.executeDelete(categoryCode, accessToken, status().isOk());
result.andExpect(jsonPath("$.payload.code", is(categoryCode)));
result.andExpect(jsonPath("$.errors", Matchers.hasSize(0)));
Assert.assertNull(this.categoryManager.getCategory(categoryCode));
} finally {
if (categoryManager.getCategory(categoryCode) != null) {
this.categoryManager.deleteCategory(categoryCode);
}
}
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestSearchEngineManager method testSearchFacetedContents_1.
public void testSearchFacetedContents_1() throws Throwable {
try {
Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
thread.join();
SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
Category general = this._categoryManager.getCategory("general");
List<ITreeNode> categories = new ArrayList<ITreeNode>();
categories.add(general);
List<String> allowedGroup = new ArrayList<String>();
allowedGroup.add(Group.FREE_GROUP_NAME);
allowedGroup.add(Group.ADMINS_GROUP_NAME);
FacetedContentsResult result = sem.searchFacetedEntities(null, categories, allowedGroup);
assertNotNull(result);
String[] expected1 = { "ART122", "ART102", "ART111", "ART120" };
this.verify(result.getContentsId(), expected1);
assertEquals(4, result.getOccurrences().size());
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestSearchEngineManager method createDataObject_1.
private DataObject createDataObject_1() {
DataObject content = new DataObject();
content.setId("100");
content.setMainGroup(Group.FREE_GROUP_NAME);
content.addGroup("secondaryGroup");
content.setTypeCode("ART");
TextAttribute text = new TextAttribute();
text.setName("Articolo");
text.setType("Text");
text.setIndexingType(IndexableAttributeInterface.INDEXING_TYPE_TEXT);
text.setText("San Pietroburgo è una città meravigliosa W3C-WAI", "it");
text.setText("St. Petersburg is a wonderful city", "en");
content.addAttribute(text);
Category category1 = this._categoryManager.getCategory("resCat2");
Category category2 = this._categoryManager.getCategory("general_cat3");
content.addCategory(category1);
content.addCategory(category2);
return content;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestSearchEngineManager method testSearchContentsId_4.
public void testSearchContentsId_4() throws Throwable {
try {
Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
thread.join();
SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
SearchEngineFilter filterByType = new SearchEngineFilter(IIndexerDAO.DATAOBJECT_TYPE_FIELD_NAME, "ART");
SearchEngineFilter[] filters = { filterByType };
List<String> allowedGroup = new ArrayList<String>();
allowedGroup.add(Group.FREE_GROUP_NAME);
List<String> contentsId = sem.searchEntityId(filters, null, allowedGroup);
assertNotNull(contentsId);
String[] expected1 = { "ART180", "ART1", "ART187", "ART121" };
this.verify(contentsId, expected1);
Category cat1 = this._categoryManager.getCategory("cat1");
List<ITreeNode> categories = new ArrayList<ITreeNode>();
categories.add(cat1);
contentsId = sem.searchEntityId(filters, categories, allowedGroup);
assertNotNull(contentsId);
String[] expected2 = { "ART180" };
this.verify(contentsId, expected2);
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestSearchEngineManager method testSearchContentsId_6.
public void testSearchContentsId_6() throws Throwable {
try {
Thread thread = this.dataObjectSearchEngineManager.startReloadDataObjectsReferences();
thread.join();
SearchEngineManager sem = (SearchEngineManager) this.dataObjectSearchEngineManager;
Category general = this._categoryManager.getCategory("general");
List<ITreeNode> categories = new ArrayList<ITreeNode>();
categories.add(general);
List<String> allowedGroup = new ArrayList<String>();
allowedGroup.add(Group.ADMINS_GROUP_NAME);
List<String> contentsId = sem.searchEntityId(null, categories, allowedGroup);
assertNotNull(contentsId);
String[] expected1 = { "ART122", "ART102", "ART111", "ART120" };
this.verify(contentsId, expected1);
} catch (Throwable t) {
throw t;
}
}
Aggregations