<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Testing on traviscj/blog</title>
    <link>https://traviscj.com/blog/tags/testing/</link>
    <description>Recent content in Testing on traviscj/blog</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 07 Jan 2019 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://traviscj.com/blog/tags/testing/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>pattern: extract mutating variables to State class</title>
      <link>https://traviscj.com/blog/post/2019-01-07-pattern_extract_mutating_variables_to_state_class/</link>
      <pubDate>Mon, 07 Jan 2019 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2019-01-07-pattern_extract_mutating_variables_to_state_class/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve come to really like the pattern of extracting local or instance variables into their own &lt;code&gt;State&lt;/code&gt; class, and writing an algorithm in terms of that &lt;code&gt;State&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;A really trivial (if contrived) example of this would be a &amp;ldquo;sum cubes&amp;rdquo; algorithm; something like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;CubeSummer&lt;/span&gt; {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;private&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;final&lt;/span&gt; PrintStream printStream;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;private&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;long&lt;/span&gt; i;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;private&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;long&lt;/span&gt; sum;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;CubeSummer&lt;/span&gt;() {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;this&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;printStream&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; System.&lt;span style=&#34;color:#a6e22e&#34;&gt;out&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    reset();&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;long&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;sumCubes&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;long&lt;/span&gt; limit) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; (; i&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;limit; i&lt;span style=&#34;color:#f92672&#34;&gt;++&lt;/span&gt;) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      sum &lt;span style=&#34;color:#f92672&#34;&gt;+=&lt;/span&gt; i &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; i &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; i;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      display();&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; sum;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;reset&lt;/span&gt;() {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    i &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; 0;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    sum &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; 0;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;display&lt;/span&gt;() {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    printStream.&lt;span style=&#34;color:#a6e22e&#34;&gt;print&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;i = &amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; i &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;;&amp;#34;&lt;/span&gt;);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    printStream.&lt;span style=&#34;color:#a6e22e&#34;&gt;println&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34; sum = &amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; sum);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;What&amp;rsquo;s happened here is we&amp;rsquo;ve essentially promoted some variables that should arguably be &lt;em&gt;local&lt;/em&gt; variables into &lt;em&gt;instance&lt;/em&gt; variables, to avoid needing to pass them around explicitly.&#xA;But in the process, we&amp;rsquo;ve also mixed long-lived state with short-lived state, broken thread safety, and forced clients of this class into a particular calling convention (either instantiate an instance per &lt;code&gt;sumCubes&lt;/code&gt; call or carefully respect thread safety and call &lt;code&gt;#reset()&lt;/code&gt;.)&lt;/p&gt;</description>
    </item>
    <item>
      <title>robustness principle and mocks</title>
      <link>https://traviscj.com/blog/post/2018-07-11-robustness-principle-and-mocks/</link>
      <pubDate>Wed, 11 Jul 2018 11:53:54 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2018-07-11-robustness-principle-and-mocks/</guid>
      <description>&lt;p&gt;The &lt;a href=&#34;https://en.wikipedia.org/wiki/Robustness_principle&#34;&gt;Robustness Principle&lt;/a&gt; (or Postel&amp;rsquo;s Law) states&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Be conservative in what you do, be liberal in what you accept from others (often reworded as &amp;ldquo;Be conservative in what you send, be liberal in what you accept&amp;rdquo;).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This principle &lt;a href=&#34;https://softwareengineering.stackexchange.com/questions/12401/be-liberal-in-what-you-accept-or-not&#34;&gt;has&lt;/a&gt; &lt;a href=&#34;http://trevorjim.com/postels-law-is-not-for-you/&#34;&gt;some&lt;/a&gt; &lt;a href=&#34;https://programmingisterrible.com/post/42215715657/postels-principle-is-a-bad-idea&#34;&gt;criticisms&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I realized this has interesting implications for &lt;a href=&#34;https://en.wikipedia.org/wiki/Mock_object&#34;&gt;mocks&lt;/a&gt;.&#xA;Suppose you have&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;public class MyObj {&#xA;  private final Integer x;&#xA;  &#xA;  public MyObj(Integer x) {&#xA;    if (x &amp;lt; 0) {&#xA;      throw new IllegalArgumentException(&amp;quot;negative x!&amp;quot;);&#xA;    }&#xA;    this.x = x;&#xA;  }&#xA;  &#xA;  public int getX() {&#xA;    return x;&#xA;  }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;In a unit test, we can have&lt;/p&gt;</description>
    </item>
    <item>
      <title>constraint violations in tests</title>
      <link>https://traviscj.com/blog/post/2018-05-31-constraint_violations_in_tests/</link>
      <pubDate>Thu, 31 May 2018 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2018-05-31-constraint_violations_in_tests/</guid>
      <description>&lt;p&gt;I had some test code that looked something like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;@Test public void a() {&#xA;  db.insert(0, &amp;quot;a&amp;quot;);&#xA;  assertThat(db.query(1).getKey()).isEqualTo(&amp;quot;a&amp;quot;);&#xA;}&#xA;&#xA;@Test public void b() {&#xA;  db.insert(0, &amp;quot;a&amp;quot;);&#xA;  db.insert(1, &amp;quot;b&amp;quot;);&#xA;  assertThat(db.query(2).getKey()).isEqualTo(&amp;quot;b&amp;quot;);&#xA;}&#xA;&#xA;@Test public void c() {&#xA;  assertThat(db.query(3)).isNull();&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;There&amp;rsquo;s some stuff to like about this:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;pretty straightforward which test is touching which records&lt;/li&gt;&#xA;&lt;li&gt;pretty clear what you expect to see in the database.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;There&amp;rsquo;s a bunch of coincidences here that make this work, though:&lt;/p&gt;</description>
    </item>
    <item>
      <title>multiple thread test cases in java</title>
      <link>https://traviscj.com/blog/post/2018-05-15-multiple_thread_test_cases_in_java/</link>
      <pubDate>Tue, 15 May 2018 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2018-05-15-multiple_thread_test_cases_in_java/</guid>
      <description>&lt;p&gt;Some of my day job lately has been trying to get a better handle on threads in Java.&#xA;In particular, we had a really weird race condition resulting from multiple threads processing an input data stream and causing some unexpected conflicts in our data access layer.&lt;/p&gt;&#xA;&lt;p&gt;To try to replicate the problem in tests, I started with something like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;private&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;static&lt;/span&gt; Runnable &lt;span style=&#34;color:#a6e22e&#34;&gt;runWithDelay&lt;/span&gt;(String name, &lt;span style=&#34;color:#66d9ef&#34;&gt;long&lt;/span&gt; millis) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; () &lt;span style=&#34;color:#f92672&#34;&gt;-&amp;gt;&lt;/span&gt; {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;try&lt;/span&gt; {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      Thread.&lt;span style=&#34;color:#a6e22e&#34;&gt;sleep&lt;/span&gt;(millis);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    } &lt;span style=&#34;color:#66d9ef&#34;&gt;catch&lt;/span&gt; (InterruptedException e) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#66d9ef&#34;&gt;throw&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; RuntimeException(e);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    System.&lt;span style=&#34;color:#a6e22e&#34;&gt;out&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;println&lt;/span&gt;(name &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34; finished&amp;#34;&lt;/span&gt;);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  };&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;p&gt;This is just a &lt;code&gt;Runnable&lt;/code&gt; that waits a while, and then prints that it finished.&#xA;Then we can test with something like:&lt;/p&gt;</description>
    </item>
    <item>
      <title>guava RangeMap</title>
      <link>https://traviscj.com/blog/post/2018-01-26-guava-rangemap/</link>
      <pubDate>Fri, 26 Jan 2018 09:52:41 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2018-01-26-guava-rangemap/</guid>
      <description>&lt;p&gt;We had some code like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;NavigableMap&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;Double, Integer&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt; PRIORITY_MULTIPLIERS &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; TreeMap&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;Double, Integer&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt;() {{ &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;{{ &amp;#34;&lt;/span&gt; }}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  put(LOW_THRESHOLD, 1);    &lt;span style=&#34;color:#75715e&#34;&gt;// (20k..40k)  =&amp;gt; 1&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  put(MEDIUM_THRESHOLD, 2); &lt;span style=&#34;color:#75715e&#34;&gt;// [40k..100k) =&amp;gt; 2&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  put(HIGH_THRESHOLD, 3);   &lt;span style=&#34;color:#75715e&#34;&gt;// [100k..+∞)  =&amp;gt; 3&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}};&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Integer &lt;span style=&#34;color:#a6e22e&#34;&gt;getPriorityMultiplier&lt;/span&gt;(Double v) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (v &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt; LOW_THRESHOLD) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; 0;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; PRIORITY_MULTIPLIERS.&lt;span style=&#34;color:#a6e22e&#34;&gt;floorEntry&lt;/span&gt;(v).&lt;span style=&#34;color:#a6e22e&#34;&gt;getValue&lt;/span&gt;()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I replaced with a [&lt;code&gt;RangeMap&lt;/code&gt;][RangeMap] that uses [&lt;code&gt;Range&lt;/code&gt;][Range] instances as keys:&#xA;[RangeMap]: &lt;a href=&#34;https://google.github.io/guava/releases/16.0/api/docs/com/google/common/collect/RangeMap.html&#34;&gt;https://google.github.io/guava/releases/16.0/api/docs/com/google/common/collect/RangeMap.html&lt;/a&gt;&#xA;[Range]: &lt;a href=&#34;https://google.github.io/guava/releases/16.0/api/docs/com/google/common/collect/Range.html&#34;&gt;https://google.github.io/guava/releases/16.0/api/docs/com/google/common/collect/Range.html&lt;/a&gt;&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;RangeMap&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;Double, Integer&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt; PRIORITY_MULTIPLIERS &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; ImmutableRangeMap.&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;Double, Long&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt;builder()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      .&lt;span style=&#34;color:#a6e22e&#34;&gt;put&lt;/span&gt;(Range.&lt;span style=&#34;color:#a6e22e&#34;&gt;lessThan&lt;/span&gt;(LOW_THRESHOLD), 0)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      .&lt;span style=&#34;color:#a6e22e&#34;&gt;put&lt;/span&gt;(Range.&lt;span style=&#34;color:#a6e22e&#34;&gt;closedOpen&lt;/span&gt;(LOW_THRESHOLD, MEDIUM_THRESHOLD), 1)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      .&lt;span style=&#34;color:#a6e22e&#34;&gt;put&lt;/span&gt;(Range.&lt;span style=&#34;color:#a6e22e&#34;&gt;closedOpen&lt;/span&gt;(MEDIUM_THRESHOLD, HIGH_THRESHOLD), 2)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      .&lt;span style=&#34;color:#a6e22e&#34;&gt;put&lt;/span&gt;(Range.&lt;span style=&#34;color:#a6e22e&#34;&gt;atLeast&lt;/span&gt;(HIGH_THRESHOLD), 3)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      .&lt;span style=&#34;color:#a6e22e&#34;&gt;build&lt;/span&gt;();&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Integer &lt;span style=&#34;color:#a6e22e&#34;&gt;getPriorityMultiplier&lt;/span&gt;(Double v) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; rangePriorityMultipliers.&lt;span style=&#34;color:#a6e22e&#34;&gt;get&lt;/span&gt;(v);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Advantages here being:&lt;/p&gt;</description>
    </item>
    <item>
      <title>switching over to https</title>
      <link>https://traviscj.com/blog/post/2016-04-15-switching_over_to_https/</link>
      <pubDate>Fri, 15 Apr 2016 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2016-04-15-switching_over_to_https/</guid>
      <description>&lt;p&gt;One of the things I&amp;rsquo;ve been meaning to do forever is switch things over to https.&#xA;By &amp;ldquo;things&amp;rdquo;, I mean the set of websites I run for some family and friends.&#xA;I tried it out with my personal website first, then flipped over the rest.&lt;/p&gt;&#xA;&lt;h2 id=&#34;implementation-notes&#34;&gt;implementation notes&lt;/h2&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;I used the &lt;a href=&#34;https://letsencrypt.org/getting-started/&#34;&gt;letsencrypt start guide&lt;/a&gt; to generate the certificates.&lt;/li&gt;&#xA;&lt;li&gt;Modified the nginx config to:&#xA;a. serve ssl/https traffic on port 443 for the given domain with the proper https certificates/etc.&#xA;b. forward non-ssl/http traffic on port 80 to port 443 for the given domain&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2 id=&#34;verification&#34;&gt;verification&lt;/h2&gt;&#xA;&lt;p&gt;It turns out that the nginx configuration files are a little bit error prone.&#xA;This probably means that I am doing something wrong, like not using some configuration management tool like puppet or ansible or whatever.&#xA;But for something as small scale as my site, it doesn&amp;rsquo;t really meet the cost-benefit threshold for learning a new tool/language.&#xA;I also even considered spinning up a simple one-off configuration generator that I&amp;rsquo;d need to figure out how to override and extend as needed.&lt;/p&gt;</description>
    </item>
    <item>
      <title>tjtestharness - a language-agnostic DVCS unit-test/continuous integration tool</title>
      <link>https://traviscj.com/blog/post/2012-03-26-tjtestharness_-_a_language-agnostic_dvcs_unit-testcontinuous_integration_tool/</link>
      <pubDate>Mon, 26 Mar 2012 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2012-03-26-tjtestharness_-_a_language-agnostic_dvcs_unit-testcontinuous_integration_tool/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve been wanting to have a way to visualize which unit tests(or sets of them) passed for a given commit, if for no other reason than the sense of accomplishment from watching boxes turn yellow, then green, as they pass tests.&#xA;The trouble is, I write code in a lot of different languages for a lot of different projects.&#xA;I also don&amp;rsquo;t want to bother with running unit tests individually&amp;ndash;I want them to run as I perform commits.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
