/*
 * Copyright 2014 bitcoinj project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.bitcoinj.core;

import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.TestNet3Params;
import org.junit.Test;

import static org.bitcoinj.core.Utils.HEX;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;

public class PrefixedChecksummedBytesTest {
    private static final NetworkParameters TESTNET = TestNet3Params.get();
    private static final NetworkParameters MAINNET = MainNetParams.get();

    private static class PrefixedChecksummedBytesToTest extends PrefixedChecksummedBytes {
        public PrefixedChecksummedBytesToTest(NetworkParameters params, byte[] bytes) {
            super(params, bytes);
        }

        @Override
        public String toString() {
            return Base58.encodeChecked(params.getAddressHeader(), bytes);
        }
    }

    @Test
    public void stringification() throws Exception {
        // Test a testnet address.
        PrefixedChecksummedBytes a = new PrefixedChecksummedBytesToTest(TESTNET, HEX.decode("fda79a24e50ff70ff42f7d89585da5bd19d9e5cc"));
        assertEquals("n4eA2nbYqErp7H6jebchxAN59DmNpksexv", a.toString());

        PrefixedChecksummedBytes b = new PrefixedChecksummedBytesToTest(MAINNET, HEX.decode("4a22c3c4cbb31e4d03b15550636762bda0baf85a"));
        assertEquals("17kzeh4N8g49GFvdDzSf8PjaPfyoD1MndL", b.toString());
    }

    @Test
    public void cloning() throws Exception {
        PrefixedChecksummedBytes a = new PrefixedChecksummedBytesToTest(TESTNET, HEX.decode("fda79a24e50ff70ff42f7d89585da5bd19d9e5cc"));
        PrefixedChecksummedBytes b = a.clone();

        assertEquals(a, b);
        assertNotSame(a, b);
    }

    @Test
    public void comparisonCloneEqualTo() throws Exception {
        PrefixedChecksummedBytes a = new PrefixedChecksummedBytesToTest(TESTNET, HEX.decode("fda79a24e50ff70ff42f7d89585da5bd19d9e5cc"));
        PrefixedChecksummedBytes b = a.clone();

        assertTrue(a.compareTo(b) == 0);
    }
}

@@ -31,16 +31,47 @@
 project%0A
+ * Copyright 2019 Tim Strasser%0A
  *%0A * Li
@@ -667,80 +667,80 @@
 org.
-bitcoinj.params.MainNetParams;%0Aimport org.bitcoinj.params.TestNet3Params
+easymock.EasyMockRunner;%0Aimport org.easymock.Mock;%0Aimport org.junit.Test
 ;%0Aim
@@ -754,20 +754,30 @@
 g.junit.
-Test
+runner.RunWith
 ;%0A%0Aimpor
@@ -927,33 +927,109 @@
 org.
-junit.Assert.assertTrue;%0A
+easymock.EasyMock.expect;%0Aimport static org.easymock.EasyMock.replay;%0A%0A@RunWith(EasyMockRunner.class)
 %0Apub
@@ -1073,155 +1073,47 @@
 t %7B%0A
-    private static final NetworkParameters TESTNET = TestNet3Params.get();%0A    private static final NetworkParameters MAINNET = MainNetParams.get()
+%0A    @Mock%0A    NetworkParameters params
 ;%0A%0A 
@@ -1523,33 +1523,16 @@
 cation()
- throws Exception
  %7B%0A     
@@ -1561,16 +1561,112 @@
 ddress.%0A
+        expect(params.getAddressHeader()).andReturn(111).andReturn(0);%0A        replay(params);%0A%0A
         
@@ -1721,39 +1721,38 @@
 mmedBytesToTest(
-TESTNET
+params
 , HEX.decode(%22fd
@@ -1945,15 +1945,14 @@
 est(
-MAINNET
+params
 , HE
@@ -2134,32 +2134,115 @@
 ows Exception %7B%0A
+        expect(params.getAddressHeader()).andReturn(111);%0A        replay(params);%0A%0A
         Prefixed
@@ -2289,39 +2289,38 @@
 mmedBytesToTest(
-TESTNET
+params
 , HEX.decode(%22fd
@@ -2537,32 +2537,186 @@
 ows Exception %7B%0A
+        expect(params.getAddressHeader()).andReturn(111);%0A        expect(params.getId()).andReturn(%22org.bitcoin.test%22).times(2);%0A        replay(params);%0A%0A
         Prefixed
@@ -2775,15 +2775,14 @@
 est(
-TESTNET
+params
 , HE
@@ -2903,13 +2903,18 @@
 sert
-True(
+Equals(0, 
 a.co
@@ -2927,13 +2927,8 @@
 o(b)
- == 0
 );%0A 

Use proper mocking around class to test.