c1045c49217477a99f08f791c0e622d394baf8c2
[website] /
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3 <head><meta http-equiv="content-type" content="text/html; charset=UTF-8" />
4 <title>FacebookErrorMessageMappingTest xref</title>
5 <link type="text/css" rel="stylesheet" href="../../../../stylesheet.css" />
6 </head>
7 <body>
8 <div id="overview"><a href="../../../../../testapidocs/de/juplo/facebook/exceptions/FacebookErrorMessageMappingTest.html">View Javadoc</a></div><pre>
9 <a class="jxr_linenumber" name="L1" href="#L1">1</a>   <strong class="jxr_keyword">package</strong> de.juplo.facebook.exceptions;
10 <a class="jxr_linenumber" name="L2" href="#L2">2</a>   
11 <a class="jxr_linenumber" name="L3" href="#L3">3</a>   <strong class="jxr_keyword">import</strong> com.fasterxml.jackson.core.JsonProcessingException;
12 <a class="jxr_linenumber" name="L4" href="#L4">4</a>   <strong class="jxr_keyword">import</strong> de.juplo.facebook.exceptions.GraphApiException.FacebookErrorMessage;
13 <a class="jxr_linenumber" name="L5" href="#L5">5</a>   <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> de.juplo.facebook.exceptions.GraphApiException.OBJECT_MAPPER;
14 <a class="jxr_linenumber" name="L6" href="#L6">6</a>   <strong class="jxr_keyword">import</strong> de.juplo.facebook.exceptions.GraphApiException.Type;
15 <a class="jxr_linenumber" name="L7" href="#L7">7</a>   <strong class="jxr_keyword">import</strong> java.io.IOException;
16 <a class="jxr_linenumber" name="L8" href="#L8">8</a>   <strong class="jxr_keyword">import</strong> org.junit.Test;
17 <a class="jxr_linenumber" name="L9" href="#L9">9</a>   <strong class="jxr_keyword">import</strong> <strong class="jxr_keyword">static</strong> org.junit.Assert.assertEquals;
18 <a class="jxr_linenumber" name="L10" href="#L10">10</a>  
19 <a class="jxr_linenumber" name="L11" href="#L11">11</a>  <em class="jxr_javadoccomment">/**</em>
20 <a class="jxr_linenumber" name="L12" href="#L12">12</a>  <em class="jxr_javadoccomment"> * @author Kai Moritz</em>
21 <a class="jxr_linenumber" name="L13" href="#L13">13</a>  <em class="jxr_javadoccomment"> */</em>
22 <a class="jxr_linenumber" name="L14" href="#L14">14</a>  <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../de/juplo/facebook/exceptions/FacebookErrorMessageMappingTest.html">FacebookErrorMessageMappingTest</a>
23 <a class="jxr_linenumber" name="L15" href="#L15">15</a>  {
24 <a class="jxr_linenumber" name="L16" href="#L16">16</a>    <strong class="jxr_keyword">final</strong> String example =
25 <a class="jxr_linenumber" name="L17" href="#L17">17</a>        <span class="jxr_string">"{"</span> +
26 <a class="jxr_linenumber" name="L18" href="#L18">18</a>            <span class="jxr_string">"\&quot;error\&quot;:{"</span> +
27 <a class="jxr_linenumber" name="L19" href="#L19">19</a>                <span class="jxr_string">"\&quot;message\&quot;:\&quot;Message describing the error\&quot;,"</span> +
28 <a class="jxr_linenumber" name="L20" href="#L20">20</a>                <span class="jxr_string">"\&quot;type\&quot;:\&quot;OAuthException\&quot;,"</span> +
29 <a class="jxr_linenumber" name="L21" href="#L21">21</a>                <span class="jxr_string">"\&quot;code\&quot;:190,"</span> +
30 <a class="jxr_linenumber" name="L22" href="#L22">22</a>                <span class="jxr_string">"\&quot;error_subcode\&quot;:460,"</span> +
31 <a class="jxr_linenumber" name="L23" href="#L23">23</a>                <span class="jxr_string">"\&quot;error_user_title\&quot;:\&quot;A title\&quot;,"</span> +
32 <a class="jxr_linenumber" name="L24" href="#L24">24</a>                <span class="jxr_string">"\&quot;error_user_msg\&quot;:\&quot;A message\&quot;,"</span> +
33 <a class="jxr_linenumber" name="L25" href="#L25">25</a>                <span class="jxr_string">"\&quot;fbtrace_id\&quot;:\&quot;EJplcsCHuLu\&quot;"</span> +
34 <a class="jxr_linenumber" name="L26" href="#L26">26</a>            <span class="jxr_string">"}"</span> +
35 <a class="jxr_linenumber" name="L27" href="#L27">27</a>        <span class="jxr_string">"}"</span>;
36 <a class="jxr_linenumber" name="L28" href="#L28">28</a>  
37 <a class="jxr_linenumber" name="L29" href="#L29">29</a>  
38 <a class="jxr_linenumber" name="L30" href="#L30">30</a>    @Test
39 <a class="jxr_linenumber" name="L31" href="#L31">31</a>    <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testSerialize() <strong class="jxr_keyword">throws</strong> JsonProcessingException
40 <a class="jxr_linenumber" name="L32" href="#L32">32</a>    {
41 <a class="jxr_linenumber" name="L33" href="#L33">33</a>      FacebookErrorMessage error = <strong class="jxr_keyword">new</strong> FacebookErrorMessage();
42 <a class="jxr_linenumber" name="L34" href="#L34">34</a>      error.message = <span class="jxr_string">"Message describing the error"</span>;
43 <a class="jxr_linenumber" name="L35" href="#L35">35</a>      error.type = Type.OAuthException.name();
44 <a class="jxr_linenumber" name="L36" href="#L36">36</a>      error.code = 190;
45 <a class="jxr_linenumber" name="L37" href="#L37">37</a>      error.subCode = 460;
46 <a class="jxr_linenumber" name="L38" href="#L38">38</a>      error.userTitle = <span class="jxr_string">"A title"</span>;
47 <a class="jxr_linenumber" name="L39" href="#L39">39</a>      error.userMessage = <span class="jxr_string">"A message"</span>;
48 <a class="jxr_linenumber" name="L40" href="#L40">40</a>      error.traceId = <span class="jxr_string">"EJplcsCHuLu"</span>;
49 <a class="jxr_linenumber" name="L41" href="#L41">41</a>  
50 <a class="jxr_linenumber" name="L42" href="#L42">42</a>      assertEquals(example, OBJECT_MAPPER.writeValueAsString(error));
51 <a class="jxr_linenumber" name="L43" href="#L43">43</a>    }
52 <a class="jxr_linenumber" name="L44" href="#L44">44</a>  
53 <a class="jxr_linenumber" name="L45" href="#L45">45</a>    @Test
54 <a class="jxr_linenumber" name="L46" href="#L46">46</a>    <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> testDeserialize() <strong class="jxr_keyword">throws</strong> IOException
55 <a class="jxr_linenumber" name="L47" href="#L47">47</a>    {
56 <a class="jxr_linenumber" name="L48" href="#L48">48</a>      FacebookErrorMessage error =
57 <a class="jxr_linenumber" name="L49" href="#L49">49</a>          OBJECT_MAPPER.readValue(example, FacebookErrorMessage.<strong class="jxr_keyword">class</strong>);
58 <a class="jxr_linenumber" name="L50" href="#L50">50</a>  
59 <a class="jxr_linenumber" name="L51" href="#L51">51</a>      assertEquals(<span class="jxr_string">"Message describing the error"</span>, error.message);
60 <a class="jxr_linenumber" name="L52" href="#L52">52</a>      assertEquals(Type.OAuthException.name(), error.type);
61 <a class="jxr_linenumber" name="L53" href="#L53">53</a>      assertEquals(<strong class="jxr_keyword">new</strong> Integer(190), error.code);
62 <a class="jxr_linenumber" name="L54" href="#L54">54</a>      assertEquals(<strong class="jxr_keyword">new</strong> Integer(460), error.subCode);
63 <a class="jxr_linenumber" name="L55" href="#L55">55</a>      assertEquals(<span class="jxr_string">"A title"</span>, error.userTitle);
64 <a class="jxr_linenumber" name="L56" href="#L56">56</a>      assertEquals(<span class="jxr_string">"A message"</span>, error.userMessage);
65 <a class="jxr_linenumber" name="L57" href="#L57">57</a>      assertEquals(<span class="jxr_string">"EJplcsCHuLu"</span>, error.traceId);
66 <a class="jxr_linenumber" name="L58" href="#L58">58</a>    }
67 <a class="jxr_linenumber" name="L59" href="#L59">59</a>  }
68 </pre>
69 <hr/>
70 <div id="footer">Copyright &#169; 2015. All rights reserved.</div>
71 </body>
72 </html>