// Path: sdk/src/main/java/com/punchthrough/bean/sdk/internal/upload/sketch/BeanSubstate.java
// public enum BeanSubstate implements EnumParse.ParsableEnum {
//     INIT(0x00),
//     WRITE_ADDRESS(0x01),
//     WRITE_ADDRESS_ACK(0x02),
//     WRITE_CHUNK(0x03),
//     WRITE_CHUNK_ACK(0x04),
//     READ_ADDRESS(0x05),
//     READ_ADDRESS_ACK(0x06),
//     READ_CHUNK(0x07),
//     READ_CHUNK_ACK(0x08),
//     VERIFY(0x09),
//     DONE(0x0A),
//     DONE_ACK(0x0B),
// 
//     START(0x0C),
//     START_ACK(0x0D),
//     HELLO(0x0E),
//     HELLO_ACK(0x0F),
//     START_RSTAGAIN(0x10),
// 
//     DONE_RESET(0x11),
//     PROG_MODE(0x12),
//     PROG_MODE_ACK(0x13),
//     DEVICE_SIG(0x14),
//     DEVICE_SIG_ACK(0x15),
//     WRITE_CHUNK_TWO(0x16),
//     ERROR(0x17);
// 
//     private final int value;
// 
//     private BeanSubstate(final int value) {
//         this.value = value;
//     }
// 
//     public int getRawValue() {
//         return value;
//     }
// }
// 
// Path: sdk/src/main/java/com/punchthrough/bean/sdk/internal/exception/NoEnumFoundException.java
// public class NoEnumFoundException extends Exception {
//     public NoEnumFoundException(String detailMessage) {
//         super(detailMessage);
//     }
// }
// 
// Path: sdk/src/main/java/com/punchthrough/bean/sdk/message/Status.java
// @AutoParcel
// public abstract class Status implements Parcelable {
//     /* AppMessages.h -> BL_MSG_STATUS_T:
//      * {
//      *     PTD_UINT8 hlState;   // BL_HL_STATE_T
//      *     PTD_UINT8 intState;  // BL_STATE_T
//      *     PTD_UINT16 blocksSent;
//      *     PTD_UINT16 bytesSent;
//      * }
//      */
// 
//     public abstract BeanState beanState();
// 
//     public abstract BeanSubstate beanSubstate();
// 
//     public abstract int blocksSent();
// 
//     public abstract int bytesSent();
// 
//     public static Status create(BeanState beanState, BeanSubstate beanSubstate, int blocksSent, int bytesSent) {
//         return new AutoParcel_Status(beanState, beanSubstate, blocksSent, bytesSent);
//     }
// 
//     public static Status fromPayload(Buffer buffer) throws NoEnumFoundException {
//         BeanState beanState = EnumParse.enumWithRawValue(BeanState.class, buffer.readByte());
//         BeanSubstate beanSubstate = EnumParse.enumWithRawValue(BeanSubstate.class, buffer.readByte());
//         int blocksSent = bytesToInt(buffer.readByte(), buffer.readByte());
//         int bytesSent = bytesToInt(buffer.readByte(), buffer.readByte());
//         return Status.create(beanState, beanSubstate, blocksSent, bytesSent);
//     }
// 
// }


import com.punchthrough.bean.sdk.internal.upload.sketch.BeanState;
import com.punchthrough.bean.sdk.internal.upload.sketch.BeanSubstate;
import com.punchthrough.bean.sdk.internal.exception.NoEnumFoundException;
import com.punchthrough.bean.sdk.message.Status;
import org.junit.Test;
import okio.Buffer;
import static org.assertj.core.api.Assertions.assertThat;
package com.punchthrough.bean.sdk.bootloader;





public class StatusTest {

    @Test
    public void testStatusFromPayload() throws NoEnumFoundException {
        Buffer buffer = new Buffer();

        buffer.writeByte(0x04);  // State: VERIFY

        buffer.writeByte(0x0E);  // Substate: HELLO

        buffer.writeByte(0x12);  // Blocks sent: 4616
        buffer.writeByte(0x08);

        buffer.writeByte(0x34);  // Bytes sent: 13393
        buffer.writeByte(0x51);

        Status status = Status.fromPayload(buffer);
        assertThat(status.beanState()).isEqualTo(BeanState.VERIFY);
// Path: sdk/src/main/java/com/punchthrough/bean/sdk/internal/upload/sketch/BeanSubstate.java
// public enum BeanSubstate implements EnumParse.ParsableEnum {
//     INIT(0x00),
//     WRITE_ADDRESS(0x01),
//     WRITE_ADDRESS_ACK(0x02),
//     WRITE_CHUNK(0x03),
//     WRITE_CHUNK_ACK(0x04),
//     READ_ADDRESS(0x05),
//     READ_ADDRESS_ACK(0x06),
//     READ_CHUNK(0x07),
//     READ_CHUNK_ACK(0x08),
//     VERIFY(0x09),
//     DONE(0x0A),
//     DONE_ACK(0x0B),
// 
//     START(0x0C),
//     START_ACK(0x0D),
//     HELLO(0x0E),
//     HELLO_ACK(0x0F),
//     START_RSTAGAIN(0x10),
// 
//     DONE_RESET(0x11),
//     PROG_MODE(0x12),
//     PROG_MODE_ACK(0x13),
//     DEVICE_SIG(0x14),
//     DEVICE_SIG_ACK(0x15),
//     WRITE_CHUNK_TWO(0x16),
//     ERROR(0x17);
// 
//     private final int value;
// 
//     private BeanSubstate(final int value) {
//         this.value = value;
//     }
// 
//     public int getRawValue() {
//         return value;
//     }
// }
// 
// Path: sdk/src/main/java/com/punchthrough/bean/sdk/internal/exception/NoEnumFoundException.java
// public class NoEnumFoundException extends Exception {
//     public NoEnumFoundException(String detailMessage) {
//         super(detailMessage);
//     }
// }
// 
// Path: sdk/src/main/java/com/punchthrough/bean/sdk/message/Status.java
// @AutoParcel
// public abstract class Status implements Parcelable {
//     /* AppMessages.h -> BL_MSG_STATUS_T:
//      * {
//      *     PTD_UINT8 hlState;   // BL_HL_STATE_T
//      *     PTD_UINT8 intState;  // BL_STATE_T
//      *     PTD_UINT16 blocksSent;
//      *     PTD_UINT16 bytesSent;
//      * }
//      */
// 
//     public abstract BeanState beanState();
// 
//     public abstract BeanSubstate beanSubstate();
// 
//     public abstract int blocksSent();
// 
//     public abstract int bytesSent();
// 
//     public static Status create(BeanState beanState, BeanSubstate beanSubstate, int blocksSent, int bytesSent) {
//         return new AutoParcel_Status(beanState, beanSubstate, blocksSent, bytesSent);
//     }
// 
//     public static Status fromPayload(Buffer buffer) throws NoEnumFoundException {
//         BeanState beanState = EnumParse.enumWithRawValue(BeanState.class, buffer.readByte());
//         BeanSubstate beanSubstate = EnumParse.enumWithRawValue(BeanSubstate.class, buffer.readByte());
//         int blocksSent = bytesToInt(buffer.readByte(), buffer.readByte());
//         int bytesSent = bytesToInt(buffer.readByte(), buffer.readByte());
//         return Status.create(beanState, beanSubstate, blocksSent, bytesSent);
//     }
// 
// }


// Path: sdk/src/test/java/com/punchthrough/bean/sdk/bootloader/StatusTest.java
import com.punchthrough.bean.sdk.internal.upload.sketch.BeanState;
import com.punchthrough.bean.sdk.internal.upload.sketch.BeanSubstate;
import com.punchthrough.bean.sdk.internal.exception.NoEnumFoundException;
import com.punchthrough.bean.sdk.message.Status;
import org.junit.Test;
import okio.Buffer;
import static org.assertj.core.api.Assertions.assertThat;

package com.punchthrough.bean.sdk.bootloader;





public class StatusTest {

    @Test
    public void testStatusFromPayload() throws NoEnumFoundException {
        Buffer buffer = new Buffer();

        buffer.writeByte(0x04);  // State: VERIFY

        buffer.writeByte(0x0E);  // Substate: HELLO

        buffer.writeByte(0x12);  // Blocks sent: 4616
        buffer.writeByte(0x08);

        buffer.writeByte(0x34);  // Bytes sent: 13393
        buffer.writeByte(0x51);

        Status status = Status.fromPayload(buffer);
        assertThat(status.beanState()).isEqualTo(BeanState.VERIFY);
        assertThat(status.beanSubstate()).isEqualTo(BeanSubstate.HELLO);