-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
479 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
.../software/amazon/smithy/typescript/codegen/protocols/cbor/CborMemberDeserVisitorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package software.amazon.smithy.typescript.codegen.protocols.cbor; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import software.amazon.smithy.model.Model; | ||
import software.amazon.smithy.model.shapes.BlobShape; | ||
import software.amazon.smithy.model.shapes.TimestampShape; | ||
import software.amazon.smithy.typescript.codegen.TypeScriptSettings; | ||
import software.amazon.smithy.typescript.codegen.TypeScriptWriter; | ||
import software.amazon.smithy.typescript.codegen.integration.ProtocolGenerator; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class CborMemberDeserVisitorTest { | ||
private CborMemberDeserVisitor subject; | ||
|
||
@BeforeEach | ||
void setup( | ||
@Mock ProtocolGenerator.GenerationContext context, | ||
@Mock Model model, | ||
@Mock TypeScriptWriter typeScriptWriter, | ||
@Mock TypeScriptSettings settings | ||
) { | ||
when(context.getModel()).thenReturn(model); | ||
when(context.getWriter()).thenReturn(typeScriptWriter); | ||
when(context.getSettings()).thenReturn(settings); | ||
|
||
subject = new CborMemberDeserVisitor( | ||
context, | ||
"data" | ||
); | ||
} | ||
|
||
@Test | ||
void blobShape(@Mock BlobShape blobShape) { | ||
// no decoder for blob in cbor. | ||
assertEquals( | ||
"data", | ||
subject.blobShape( | ||
blobShape | ||
) | ||
); | ||
} | ||
|
||
@Test | ||
void timestampShape(@Mock TimestampShape timestampShape) { | ||
// protocol always uses this timestamp format. | ||
assertEquals( | ||
"__expectNonNull(__parseEpochTimestamp(data))", | ||
subject.timestampShape(timestampShape) | ||
); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
...va/software/amazon/smithy/typescript/codegen/protocols/cbor/CborMemberSerVisitorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package software.amazon.smithy.typescript.codegen.protocols.cbor; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import software.amazon.smithy.model.Model; | ||
import software.amazon.smithy.model.shapes.BlobShape; | ||
import software.amazon.smithy.model.shapes.DoubleShape; | ||
import software.amazon.smithy.model.shapes.FloatShape; | ||
import software.amazon.smithy.model.shapes.TimestampShape; | ||
import software.amazon.smithy.typescript.codegen.TypeScriptWriter; | ||
import software.amazon.smithy.typescript.codegen.integration.ProtocolGenerator; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.Mockito.lenient; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class CborMemberSerVisitorTest { | ||
|
||
private CborMemberSerVisitor subject; | ||
|
||
@BeforeEach | ||
void setup( | ||
@Mock ProtocolGenerator.GenerationContext context, | ||
@Mock Model model, | ||
@Mock TypeScriptWriter typeScriptWriter | ||
) { | ||
when(context.getModel()).thenReturn(model); | ||
lenient().when(context.getWriter()).thenReturn(typeScriptWriter); | ||
|
||
subject = new CborMemberSerVisitor( | ||
context, | ||
"data" | ||
); | ||
} | ||
|
||
@Test | ||
void blobShape(@Mock BlobShape blob) { | ||
// no encoder for blob in cbor. | ||
assertEquals( | ||
"data", | ||
subject.blobShape(blob) | ||
); | ||
} | ||
|
||
@Test | ||
void floatShape(@Mock FloatShape floatShape) { | ||
// no serializer function for float in cbor. | ||
assertEquals( | ||
"data", | ||
subject.floatShape(floatShape) | ||
); | ||
} | ||
|
||
@Test | ||
void doubleShape(@Mock DoubleShape doubleShape) { | ||
// no serializer function for double in cbor. | ||
assertEquals( | ||
"data", | ||
subject.doubleShape(doubleShape) | ||
); | ||
} | ||
|
||
@Test | ||
void timestampShape(@Mock TimestampShape timestampShape) { | ||
assertEquals( | ||
"__dateToTag(data)", | ||
subject.timestampShape(timestampShape) | ||
); | ||
} | ||
} |
Oops, something went wrong.