// Path: fauxflake-core/src/main/java/com/github/rholder/fauxflake/provider/MacMachineIdProvider.java
// public class MacMachineIdProvider implements MachineIdProvider {
// 
//     private final long machineId;
// 
//     public MacMachineIdProvider() {
//         long value = 0L;
//         try {
//             // first 6 bytes are MAC
//             byte[] raw = Arrays.copyOf(macAddress(), 8);
//             value = new DataInputStream(new ByteArrayInputStream(raw)).readLong();
//         } catch (Throwable t) {
//             t.printStackTrace();
//         }
//         machineId = value;
//     }
// 
//     /**
//      * Return the unique machine id based on the MAC address or 0 if an error
//      * occurs.
//      */
//     @Override
//     public long getMachineId() {
//         return machineId;
//     }
// }
// 
// Path: fauxflake-core/src/main/java/com/github/rholder/fauxflake/provider/MacPidMachineIdProvider.java
// public class MacPidMachineIdProvider implements MachineIdProvider {
// 
//     private final long machineId;
// 
//     public MacPidMachineIdProvider() {
//         long value = 0L;
//         try {
//             // first 6 bytes are MAC
//             byte[] raw = Arrays.copyOf(macAddress(), 8);
//             value = new DataInputStream(new ByteArrayInputStream(raw)).readLong();
// 
//             // next 2 bytes are pid % 2^16
//             value |= pid() % 65536;
//         } catch (Throwable t) {
//             t.printStackTrace();
//         }
//         machineId = value;
//     }
// 
//     /**
//      * Return the unique machine id based on the MAC address and current PID of
//      * the running JVM or 0 if an error occurs.
//      */
//     @Override
//     public long getMachineId() {
//         return machineId;
//     }
// }


import static org.powermock.api.mockito.PowerMockito.mockStatic;
import static org.powermock.api.mockito.PowerMockito.when;
import com.github.rholder.fauxflake.provider.MacMachineIdProvider;
import com.github.rholder.fauxflake.provider.MacPidMachineIdProvider;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;
/*
 * Copyright 2012-2014 Ray Holder
 *
 * 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 com.github.rholder.fauxflake.util;




@RunWith(PowerMockRunner.class)
@PrepareForTest({MacUtils.class, NetworkInterface.class})
public class MacUtilsMockTest {

    @Test
    public void alwaysUnsupported() {
        mockStatic(MacUtils.class);
        when(MacUtils.macAddress()).thenThrow(new UnsupportedOperationException());

// Path: fauxflake-core/src/main/java/com/github/rholder/fauxflake/provider/MacMachineIdProvider.java
// public class MacMachineIdProvider implements MachineIdProvider {
// 
//     private final long machineId;
// 
//     public MacMachineIdProvider() {
//         long value = 0L;
//         try {
//             // first 6 bytes are MAC
//             byte[] raw = Arrays.copyOf(macAddress(), 8);
//             value = new DataInputStream(new ByteArrayInputStream(raw)).readLong();
//         } catch (Throwable t) {
//             t.printStackTrace();
//         }
//         machineId = value;
//     }
// 
//     /**
//      * Return the unique machine id based on the MAC address or 0 if an error
//      * occurs.
//      */
//     @Override
//     public long getMachineId() {
//         return machineId;
//     }
// }
// 
// Path: fauxflake-core/src/main/java/com/github/rholder/fauxflake/provider/MacPidMachineIdProvider.java
// public class MacPidMachineIdProvider implements MachineIdProvider {
// 
//     private final long machineId;
// 
//     public MacPidMachineIdProvider() {
//         long value = 0L;
//         try {
//             // first 6 bytes are MAC
//             byte[] raw = Arrays.copyOf(macAddress(), 8);
//             value = new DataInputStream(new ByteArrayInputStream(raw)).readLong();
// 
//             // next 2 bytes are pid % 2^16
//             value |= pid() % 65536;
//         } catch (Throwable t) {
//             t.printStackTrace();
//         }
//         machineId = value;
//     }
// 
//     /**
//      * Return the unique machine id based on the MAC address and current PID of
//      * the running JVM or 0 if an error occurs.
//      */
//     @Override
//     public long getMachineId() {
//         return machineId;
//     }
// }


// Path: fauxflake-core/src/test/java/com/github/rholder/fauxflake/util/MacUtilsMockTest.java
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import static org.powermock.api.mockito.PowerMockito.when;
import com.github.rholder.fauxflake.provider.MacMachineIdProvider;
import com.github.rholder.fauxflake.provider.MacPidMachineIdProvider;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;

/*
 * Copyright 2012-2014 Ray Holder
 *
 * 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 com.github.rholder.fauxflake.util;




@RunWith(PowerMockRunner.class)
@PrepareForTest({MacUtils.class, NetworkInterface.class})
public class MacUtilsMockTest {

    @Test
    public void alwaysUnsupported() {
        mockStatic(MacUtils.class);
        when(MacUtils.macAddress()).thenThrow(new UnsupportedOperationException());

        Assert.assertTrue(new MacMachineIdProvider().getMachineId() == 0);