use of io.apiman.manager.api.es.beans.PoliciesBean in project apiman by apiman.
the class EsStorage method createPlanVersion.
/**
* @see io.apiman.manager.api.core.IStorage#createPlanVersion(io.apiman.manager.api.beans.plans.PlanVersionBean)
*/
@Override
public void createPlanVersion(PlanVersionBean version) throws StorageException {
PlanBean plan = version.getPlan();
String id = id(plan.getOrganization().getId(), plan.getId(), version.getVersion());
indexEntity(INDEX_MANAGER_POSTFIX_PLAN_VERSION, id, EsMarshalling.marshall(version));
PoliciesBean policies = PoliciesBean.from(PolicyType.Plan, plan.getOrganization().getId(), plan.getId(), version.getVersion());
indexEntity(INDEX_MANAGER_POSTFIX_PLAN_POLICIES, id, EsMarshalling.marshall(policies));
}
use of io.apiman.manager.api.es.beans.PoliciesBean in project apiman by apiman.
the class EsMarshallingTest method testMarshallPoliciesBean.
/**
* Test method for {@link io.apiman.manager.api.es.EsMarshalling#marshall(io.apiman.manager.api.es.beans.PoliciesBean)}.
*/
@Test
public void testMarshallPoliciesBean() throws Exception {
PoliciesBean bean = new PoliciesBean();
bean.setEntityId("ENTITY_ID");
bean.setOrganizationId("ORG_ID");
bean.setEntityVersion("VERSION");
bean.setType(PolicyType.Api);
XContentBuilder builder = EsMarshalling.marshall(bean);
Assert.assertEquals("{\"organizationId\":\"ORG_ID\",\"entityId\":\"ENTITY_ID\",\"entityVersion\":\"VERSION\",\"type\":\"Api\"}", Strings.toString(builder));
PolicyBean policy = new PolicyBean();
policy.setCreatedBy("CREATED_BY");
policy.setCreatedOn(new Date(1));
policy.setConfiguration("CONFIGURATION");
policy.setDescription("DESCRIPTION HERE.");
policy.setEntityId("ENTITY_ID");
policy.setEntityVersion("ENTITY_VERSION");
policy.setId(17L);
policy.setModifiedBy("MODIFIED_BY");
policy.setModifiedOn(new Date(2));
policy.setName("NAME");
policy.setOrderIndex(9);
policy.setOrganizationId("ORG_ID");
policy.setType(PolicyType.Api);
policy.setDefinition(new PolicyDefinitionBean());
policy.getDefinition().setDeleted(false);
policy.getDefinition().setDescription("POLICY_DEF_DESCRIPTION");
policy.getDefinition().setForm("FORM");
policy.getDefinition().setFormType(PolicyFormType.JsonSchema);
policy.getDefinition().setIcon("ICON");
policy.getDefinition().setId("POLICY_DEF_ID");
policy.getDefinition().setName("POLICY DEF NAME");
policy.getDefinition().setPluginId(27L);
policy.getDefinition().setPolicyImpl("POLICY_IMPL");
PolicyDefinitionTemplateBean template = new PolicyDefinitionTemplateBean();
template.setTemplate("TEMPLATE");
template.setLanguage("EN_US");
policy.getDefinition().getTemplates().add(template);
bean.getPolicies().add(policy);
builder = EsMarshalling.marshall(bean);
Assert.assertEquals("{\"organizationId\":\"ORG_ID\",\"entityId\":\"ENTITY_ID\",\"entityVersion\":\"VERSION\",\"type\":\"Api\",\"policies\":[" + "{\"id\":17,\"name\":\"NAME\",\"configuration\":\"CONFIGURATION\",\"createdBy\":\"CREATED_BY\",\"createdOn\":1,\"modifiedBy\":\"MODIFIED_BY\",\"modifiedOn\":2,\"definitionId\":\"POLICY_DEF_ID\",\"orderIndex\":9}]}", Strings.toString(builder));
}
Aggregations