View Javadoc
1   /*
2    * Copyright (c) 2002-2023, City of Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.broadcastproxy.business.providers.mock;
35  
36  import java.util.ArrayList;
37  import java.util.HashMap;
38  import java.util.List;
39  import java.util.Map;
40  
41  import org.json.simple.JSONObject;
42  
43  import fr.paris.lutece.plugins.broadcastproxy.business.Feed;
44  import fr.paris.lutece.plugins.broadcastproxy.business.IBroadcastProvider;
45  import fr.paris.lutece.plugins.broadcastproxy.business.Subscription;
46  
47  public class MockProvider implements IBroadcastProvider
48  {
49  
50      private static final String DEFAULT_USER_SUBSCRIPTIONS_JSON = "{\"subscriptions\":[{\"name\":\"EXAMPLE_ONE\",\"active\":\"0\"},{\"name\":\"EXAMPLE_TWO\",\"active\":\"1\",\"data\":[\"data1\",\"date2\"]}]}";
51      private static final Map<String, String> DEFAULT_USER_SUBSCRIPTIONS_MAP = createDefaultMap( );
52  
53      /**
54       * initialize default map
55       * 
56       * @return the map
57       */
58      private static Map<String, String> createDefaultMap( )
59      {
60          Map<String, String> myMap = new HashMap<>( );
61          myMap.put( "1", "sub1" );
62          myMap.put( "2", "sub2" );
63          return myMap;
64      }
65  
66      @Override
67      public String getName( )
68      {
69          return "Mock";
70      }
71  
72  
73      public boolean updateSubscribtions( List<Subscription> subscriptionsList )
74      {
75          return true;
76      }
77  
78  
79      @Override
80      public boolean update( Subscription subscription, String strAccountId ) throws Exception
81      {
82          return true;
83      }
84  
85      public List<Feed> getFeeds( )
86      {
87          List<Feed> list = new ArrayList<>( );
88  
89          Feedplugins/broadcastproxy/business/Feed.html#Feed">Feed testFeed = new Feed( );
90          testFeed.setActive( true );
91          testFeed.setName( "EXAMPLE_ONE" );
92          testFeed.setId( "ONE" );
93          testFeed.setDescription( "Test" );
94          testFeed.setType( "TEST" );
95          Map<String, String> mapDatas = new HashMap<>( );
96          mapDatas.put( "T1", "theme1" );
97          mapDatas.put( "T2", "theme2" );
98          testFeed.setData( mapDatas );
99  
100         list.add( testFeed );
101 
102         Feedlugins/broadcastproxy/business/Feed.html#Feed">Feed testFeed2 = new Feed( );
103         testFeed2.setActive( false );
104         testFeed2.setName( "EXAMPLE_TWO" );
105         testFeed2.setId( "TWO" );
106         testFeed2.setDescription( "Test" );
107         testFeed2.setType( "TEST" );
108 
109         list.add( testFeed2 );
110 
111         return list;
112     }
113 
114     @Override
115     public boolean updateSubscribtions( String userId, String jsonSubscriptions, String strAccountId ) throws Exception
116     {
117         // TODO Auto-generated method stub
118         return false;
119     }
120 
121     @Override
122     public boolean updateSubscribtions( String userId, List<Subscription> subscriptionsList ) throws Exception
123     {
124         // TODO Auto-generated method stub
125         return false;
126     }
127 
128     @Override
129     public String getAllSubscriptionByGroup( String typeSubscription, String strAccountId )
130     {
131         // TODO Auto-generated method stub
132         return null;
133     }
134 
135     @Override
136     public List<JSONObject> getUserSubscriptionIds( String strUserId, String strAccountId )
137     {
138         // TODO Auto-generated method stub
139         return null;
140     }
141 
142     @Override
143     public boolean updateArrondissementSubscribtions( String userId, String jsonSubscriptions, String strAccountId ) throws Exception
144     {
145         // TODO Auto-generated method stub
146         return false;
147     }
148 }