### Question:
CoapTcpCSM { public BlockSize getBlockSize() { if (isBERTEnabled()) { return BlockSize.S_1024_BERT; } if (isBlockTransferEnabled()) { if (maxMessageSize >= 1024) { return BlockSize.S_1024; } else if (maxMessageSize >= 512) { return BlockSize.S_512; } else if (maxMessageSize >= 256) { return BlockSize.S_256; } else if (maxMessageSize >= 128) { return BlockSize.S_128; } else if (maxMessageSize >= 64) { return BlockSize.S_64; } else if (maxMessageSize >= 32) { return BlockSize.S_32; } else { return BlockSize.S_16; } } return null; } CoapTcpCSM(long maxMessageSize, boolean blockwiseTransfer); static CoapTcpCSM min(CoapTcpCSM cap1, CoapTcpCSM cap2); CoapTcpCSM withNewOptions(Long maxMessageSize, Boolean blockwiseTransfer); boolean isBlockTransferEnabled(); boolean useBlockTransfer(byte[] payload); long getMaxMessageSize(); int getMaxMessageSizeInt(); boolean isBERTEnabled(); BlockSize getBlockSize(); int getMaxOutboundPayloadSize(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final CoapTcpCSM BASE; }### Answer:
@Test public void blockSize() { assertEquals(null, new CoapTcpCSM(20, false).getBlockSize()); assertEquals(null, new CoapTcpCSM(10242, false).getBlockSize()); assertEquals(BlockSize.S_16, new CoapTcpCSM(16, true).getBlockSize()); assertEquals(BlockSize.S_32, new CoapTcpCSM(32, true).getBlockSize()); assertEquals(BlockSize.S_64, new CoapTcpCSM(64, true).getBlockSize()); assertEquals(BlockSize.S_128, new CoapTcpCSM(128, true).getBlockSize()); assertEquals(BlockSize.S_256, new CoapTcpCSM(256, true).getBlockSize()); assertEquals(BlockSize.S_512, new CoapTcpCSM(512, true).getBlockSize()); assertEquals(BlockSize.S_512, new CoapTcpCSM(1023, true).getBlockSize()); assertEquals(BlockSize.S_1024, new CoapTcpCSM(1024, true).getBlockSize()); assertEquals(BlockSize.S_1024, new CoapTcpCSM(1025, true).getBlockSize()); assertEquals(BlockSize.S_1024_BERT, new CoapTcpCSM(1153, true).getBlockSize()); }