2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.dmaap.dbcapi.model;
22 import static org.junit.Assert.*;
24 import java.lang.reflect.Constructor;
25 import java.lang.reflect.InvocationTargetException;
26 import java.lang.reflect.Method;
27 import java.lang.reflect.Type;
29 import org.junit.After;
30 import org.junit.Before;
31 import org.junit.Test;
33 import static java.lang.System.out;
34 import static java.lang.System.err;
36 public class DmaapObjectFactory {
39 * we use localhost for most references so that connection attempts will resolve and not retry
40 * but still we expect that requests will fail.
42 private static final String fmt = "%24s: %s%n";
43 private static final String dmaap_name = "onap-ut";
44 private static final String dmaap_ver = "1";
45 private static final String dmaap_topic_root = "org.onap.dmaap";
46 private static final String dmaap_dr = "https://localhost:8443";
47 private static final String dmaap_log_url = "http://localhost:8080/log";
48 private static final String dmaap_mm_topic = "org.onap.dmaap.dcae.MM_AGENT_TOPIC";
49 private static final String central_loc = "SanFrancisco";
50 private static final String central_layer = "central-cloud";
51 private static final String central_clli = "SFCAL19240";
52 private static final String central_zone = "osaz01";
53 private static final String central_subnet = "10.10.10.0/24";
54 private static final String central_cluster_fqdn = "localhost";
55 private static final String pub_role = "org.onap.vnfapp.publisher";
56 private static final String sub_role = "org.onap.vnfapp.subscriber";
57 private static final String edge_loc = "Atlanta";
58 private static final String edge_layer = "edge-cloud";
59 private static final String edge_clli = "ATLGA10245";
60 private static final String edge_zone = "osaz02";
61 private static final String edge_subnet = "10.10.20.0/24";
62 private static final String edge_cluster_fqdn = "localhost";
63 private static final String[]hosts = { "host1", "host2", "host3" };
65 public Dmaap genDmaap() {
66 return new Dmaap( dmaap_ver, dmaap_topic_root, dmaap_name, dmaap_dr, dmaap_log_url, dmaap_mm_topic, "nk", "ako" );
69 public DcaeLocation genDcaeLocation( String layer ) {
70 if ( layer.contains( "edge" ) ) {
71 return new DcaeLocation( edge_clli, edge_layer, edge_loc, edge_zone, edge_subnet );
73 return new DcaeLocation( central_clli, central_layer, central_loc, central_zone, central_subnet );
77 public MR_Cluster genMR_Cluster( String layer ) {
78 if ( layer.contains( "edge" ) ) {
79 return new MR_Cluster( edge_loc, edge_cluster_fqdn, "ignore", hosts );
81 return new MR_Cluster( central_loc, central_cluster_fqdn, "ignore", hosts );
84 public Topic genSimpleTopic( String tname ) {
85 Topic t = new Topic();
86 t.setTopicName( tname );
87 t.setFqtnStyle( FqtnType.Validator("none") );
92 public MR_Client genMR_Client( String l, String f, String r, String[] a ) {
93 if ( l.contains( "edge" ) ) {
94 return new MR_Client( edge_loc, f, r, a );
96 return new MR_Client( central_loc, f, r, a );
99 public MR_Client genPublisher( String layer, String fqtn ) {
100 String[] actions = { "pub", "view" };
101 return genMR_Client( layer, fqtn, pub_role, actions );
103 public MR_Client genSubscriber( String layer, String fqtn ) {
104 String[] actions = { "sub", "view" };
105 return genMR_Client( layer, fqtn, sub_role, actions );
108 public DR_Sub genDrSub( String l, String feed ) {
110 String up = "secretW0rd";
111 String du = "sub.server.onap.org:8443/deliver/here";
112 String lu = "https://drps.onap.org:8443/sublog/123";
115 if ( l.contains( "edge" ) ) {
116 return new DR_Sub( edge_loc, un, up, feed, du, lu, u100 );
118 return new DR_Sub( central_loc, un, up, feed, du, lu, u100 );