X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=models-provider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fmodels%2Fprovider%2Fimpl%2FDummyPolicyModelsProviderImpl.java;h=465685c3efdc9830ef73e1933554882164b7788b;hb=9c5d23395918a739b591667edd77e3ced9cd4bfb;hp=8d833a53db8503648675d34e583e3408e52b6bbf;hpb=95dbf7256c17aa4376fa2a291ce26301cbce7029;p=policy%2Fmodels.git diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java index 8d833a53d..465685c3e 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,21 +21,27 @@ package org.onap.policy.models.provider.impl; -import com.google.gson.Gson; - +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import javax.ws.rs.core.Response; -import lombok.NonNull; +import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; -import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.pap.concepts.PdpGroups; +import org.onap.policy.models.pdp.concepts.Pdp; +import org.onap.policy.models.pdp.concepts.PdpGroup; +import org.onap.policy.models.pdp.concepts.PdpGroupFilter; +import org.onap.policy.models.pdp.concepts.PdpStatistics; +import org.onap.policy.models.pdp.concepts.PdpSubGroup; import org.onap.policy.models.provider.PolicyModelsProvider; import org.onap.policy.models.provider.PolicyModelsProviderParameters; -import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy; -import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.simple.serialization.ToscaServiceTemplateMessageBodyHandler; /** * This class provides a dummy implementation of the Policy Models Provider for the ONAP Policy Framework. @@ -49,7 +55,8 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { * * @param parameters the parameters for the provider */ - public DummyPolicyModelsProviderImpl(@NonNull final PolicyModelsProviderParameters parameters) { + public DummyPolicyModelsProviderImpl(final PolicyModelsProviderParameters parameters) { + // Default constructor } @Override @@ -63,112 +70,165 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { } @Override - public ToscaServiceTemplate getPolicyTypes(@NonNull final PfConceptKey policyTypeKey) throws PfModelException { + public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException { return getDummyResponse("dummyimpl/DummyToscaPolicyTypeGetResponse.json"); } @Override - public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate) - throws PfModelException { + public List getPolicyTypeList(final String name, final String version) throws PfModelException { + return new ArrayList<>(); + } + + @Override + public ToscaServiceTemplate getFilteredPolicyTypes(ToscaPolicyTypeFilter filter) throws PfModelException { + return getDummyResponse("dummyimpl/DummyToscaPolicyTypeGetResponse.json"); + } + + @Override + public List getFilteredPolicyTypeList(ToscaPolicyTypeFilter filter) { + return new ArrayList<>(); + } + + @Override + public ToscaServiceTemplate createPolicyTypes(final ToscaServiceTemplate serviceTemplate) throws PfModelException { return serviceTemplate; } @Override - public ToscaServiceTemplate updatePolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate) - throws PfModelException { + public ToscaServiceTemplate updatePolicyTypes(final ToscaServiceTemplate serviceTemplate) throws PfModelException { return serviceTemplate; } @Override - public ToscaServiceTemplate deletePolicyTypes(@NonNull final PfConceptKey policyTypeKey) throws PfModelException { + public ToscaServiceTemplate deletePolicyType(final String name, final String version) throws PfModelException { return getDummyResponse("dummyimpl/DummyToscaPolicyTypeDeleteResponse.json"); } @Override - public ToscaServiceTemplate getPolicies(@NonNull final PfConceptKey policyKey) throws PfModelException { + public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException { return getDummyResponse("dummyimpl/DummyToscaPolicyGetResponse.json"); } @Override - public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate) - throws PfModelException { + public List getPolicyList(final String name, final String version) throws PfModelException { + return new ArrayList<>(); + } + + @Override + public ToscaServiceTemplate getFilteredPolicies(ToscaPolicyFilter filter) throws PfModelException { + return getDummyResponse("dummyimpl/DummyToscaPolicyGetResponse.json"); + } + + @Override + public List getFilteredPolicyList(ToscaPolicyFilter filter) throws PfModelException { + return new ArrayList<>(); + } + + @Override + public ToscaServiceTemplate createPolicies(final ToscaServiceTemplate serviceTemplate) throws PfModelException { return serviceTemplate; } @Override - public ToscaServiceTemplate updatePolicies(@NonNull final ToscaServiceTemplate serviceTemplate) - throws PfModelException { + public ToscaServiceTemplate updatePolicies(final ToscaServiceTemplate serviceTemplate) throws PfModelException { return serviceTemplate; } @Override - public ToscaServiceTemplate deletePolicies(@NonNull final PfConceptKey policyKey) throws PfModelException { + public ToscaServiceTemplate deletePolicy(final String name, final String version) throws PfModelException { return getDummyResponse("dummyimpl/DummyToscaPolicyDeleteResponse.json"); } @Override - public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId) throws PfModelException { + public LegacyOperationalPolicy getOperationalPolicy(final String policyId, final String policyVersion) + throws PfModelException { return new LegacyOperationalPolicy(); } @Override - public LegacyOperationalPolicy createOperationalPolicy( - @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException { + public LegacyOperationalPolicy createOperationalPolicy(final LegacyOperationalPolicy legacyOperationalPolicy) + throws PfModelException { return legacyOperationalPolicy; } @Override - public LegacyOperationalPolicy updateOperationalPolicy( - @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException { + public LegacyOperationalPolicy updateOperationalPolicy(final LegacyOperationalPolicy legacyOperationalPolicy) + throws PfModelException { return legacyOperationalPolicy; } @Override - public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId) throws PfModelException { + public LegacyOperationalPolicy deleteOperationalPolicy(final String policyId, final String policyVersion) + throws PfModelException { return new LegacyOperationalPolicy(); } @Override - public LegacyGuardPolicy getGuardPolicy(@NonNull final String policyId) throws PfModelException { - return new LegacyGuardPolicy(); + public List getPdpGroups(final String name) throws PfModelException { + return new ArrayList<>(); } @Override - public LegacyGuardPolicy createGuardPolicy(@NonNull final LegacyGuardPolicy legacyGuardPolicy) - throws PfModelException { - return legacyGuardPolicy; + public List getFilteredPdpGroups(PdpGroupFilter filter) throws PfModelException { + return new ArrayList<>(); } @Override - public LegacyGuardPolicy updateGuardPolicy(@NonNull final LegacyGuardPolicy legacyGuardPolicy) - throws PfModelException { - return legacyGuardPolicy; + public List createPdpGroups(final List pdpGroups) throws PfModelException { + return new ArrayList<>(); + } + + @Override + public List updatePdpGroups(final List pdpGroups) throws PfModelException { + return new ArrayList<>(); } @Override - public LegacyGuardPolicy deleteGuardPolicy(@NonNull final String policyId) throws PfModelException { - return new LegacyGuardPolicy(); + public void updatePdpSubGroup(final String pdpGroupName, final PdpSubGroup pdpSubGroup) throws PfModelException { + // Not implemented } @Override - public PdpGroups getPdpGroups(@NonNull String pdpGroupFilter) throws PfModelException { - return new PdpGroups(); + public void updatePdp(String pdpGroupName, String pdpSubGroup, Pdp pdp) throws PfModelException { + // Not implemented } @Override - public PdpGroups createPdpGroups(@NonNull PdpGroups pdpGroups) throws PfModelException { - return new PdpGroups(); + public PdpGroup deletePdpGroup(final String name) throws PfModelException { + return null; } @Override - public PdpGroups updatePdpGroups(@NonNull PdpGroups pdpGroups) throws PfModelException { - return new PdpGroups(); + public List getPdpStatistics(final String name, final Date timestamp) throws PfModelException { + return new ArrayList<>(); + } + + @Override + public List getFilteredPdpStatistics(String name, String pdpGroupName, String pdpSubGroup, + Date startTimeStamp, Date endTimeStamp, String sortOrder, int getRecordNum) { + // Not implemented + return new ArrayList<>(); + } + + @Override + public List createPdpStatistics(final List pdpStatisticsList) + throws PfModelException { + // Not implemented + return new ArrayList<>(); + } + + @Override + public List updatePdpStatistics(final List pdpStatisticsList) + throws PfModelException { + // Not implemented + return new ArrayList<>(); } @Override - public PdpGroups deletePdpGroups(@NonNull String pdpGroupFilter) throws PfModelException { - return new PdpGroups(); + public List deletePdpStatistics(final String name, final Date timestamp) { + // Not implemented + return new ArrayList<>(); } /** @@ -177,12 +237,13 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { * @param fileName the file name containing the dummy response * @return the ToscaServiceTemplate with the dummy response */ - protected ToscaServiceTemplate getDummyResponse(@NonNull final String fileName) { - Gson gson = new ToscaServiceTemplateMessageBodyHandler().getGson(); + protected ToscaServiceTemplate getDummyResponse(final String fileName) { + StandardCoder standardCoder = new StandardCoder(); ToscaServiceTemplate serviceTemplate; try { - serviceTemplate = gson.fromJson(ResourceUtils.getResourceAsString(fileName), ToscaServiceTemplate.class); + serviceTemplate = + standardCoder.decode(ResourceUtils.getResourceAsString(fileName), ToscaServiceTemplate.class); if (serviceTemplate == null) { throw new PfModelException(Response.Status.INTERNAL_SERVER_ERROR, "error reading specified file"); }