1212import com .azure .core .http .HttpResponse ;
1313import com .azure .core .util .Context ;
1414import com .azure .storage .common .DownloadContentValidationOptions ;
15+ import com .azure .storage .common .implementation .Constants ;
1516import org .junit .jupiter .api .Test ;
1617import org .mockito .Mockito ;
1718import reactor .core .publisher .Flux ;
2829import static org .mockito .Mockito .when ;
2930
3031/**
31- * Unit tests for {@link StructuredMessageDecoderPolicy }.
32+ * Unit tests for {@link StorageContentValidationDecoderPolicy }.
3233 */
33- public class StructuredMessageDecoderPolicyTest {
34+ public class StorageContentValidationDecoderPolicyTest {
3435
3536 @ Test
3637 public void shouldNotApplyDecodingWhenContextKeyNotPresent () throws MalformedURLException {
3738 // Arrange
38- StructuredMessageDecoderPolicy policy = new StructuredMessageDecoderPolicy ();
39+ StorageContentValidationDecoderPolicy policy = new StorageContentValidationDecoderPolicy ();
3940 HttpPipelineCallContext context = createMockContext (null , null );
4041 HttpPipelineNextPolicy nextPolicy = createMockNextPolicy ();
4142
@@ -54,8 +55,8 @@ public void shouldNotApplyDecodingWhenContextKeyNotPresent() throws MalformedURL
5455 @ Test
5556 public void shouldNotApplyDecodingWhenContextKeyIsFalse () throws MalformedURLException {
5657 // Arrange
57- StructuredMessageDecoderPolicy policy = new StructuredMessageDecoderPolicy ();
58- Context ctx = new Context (StructuredMessageDecoderPolicy .STRUCTURED_MESSAGE_DECODING_CONTEXT_KEY , false );
58+ StorageContentValidationDecoderPolicy policy = new StorageContentValidationDecoderPolicy ();
59+ Context ctx = new Context (Constants .STRUCTURED_MESSAGE_DECODING_CONTEXT_KEY , false );
5960 HttpPipelineCallContext context = createMockContext (ctx , null );
6061 HttpPipelineNextPolicy nextPolicy = createMockNextPolicy ();
6162
@@ -74,12 +75,12 @@ public void shouldNotApplyDecodingWhenContextKeyIsFalse() throws MalformedURLExc
7475 @ Test
7576 public void shouldApplyDecodingWhenContextKeyIsTrue () throws MalformedURLException {
7677 // Arrange
77- StructuredMessageDecoderPolicy policy = new StructuredMessageDecoderPolicy ();
78+ StorageContentValidationDecoderPolicy policy = new StorageContentValidationDecoderPolicy ();
7879 DownloadContentValidationOptions validationOptions = new DownloadContentValidationOptions ()
7980 .setStructuredMessageValidationEnabled (true );
8081
81- Context ctx = new Context (StructuredMessageDecoderPolicy .STRUCTURED_MESSAGE_DECODING_CONTEXT_KEY , true )
82- .addData (StructuredMessageDecoderPolicy .STRUCTURED_MESSAGE_VALIDATION_OPTIONS_CONTEXT_KEY , validationOptions );
82+ Context ctx = new Context (Constants .STRUCTURED_MESSAGE_DECODING_CONTEXT_KEY , true )
83+ .addData (Constants .STRUCTURED_MESSAGE_VALIDATION_OPTIONS_CONTEXT_KEY , validationOptions );
8384
8485 HttpPipelineCallContext context = createMockContext (ctx , 1024L );
8586 HttpPipelineNextPolicy nextPolicy = createMockNextPolicy ();
@@ -93,20 +94,20 @@ public void shouldApplyDecodingWhenContextKeyIsTrue() throws MalformedURLExcepti
9394 assertNotNull (response );
9495 assertEquals (200 , response .getStatusCode ());
9596 // Verify it's a DecodedResponse
96- assertTrue (response instanceof StructuredMessageDecoderPolicy .DecodedResponse );
97+ assertTrue (response instanceof StorageContentValidationDecoderPolicy .DecodedResponse );
9798 })
9899 .verifyComplete ();
99100 }
100101
101102 @ Test
102103 public void shouldNotApplyDecodingForNonDownloadResponse () throws MalformedURLException {
103104 // Arrange
104- StructuredMessageDecoderPolicy policy = new StructuredMessageDecoderPolicy ();
105+ StorageContentValidationDecoderPolicy policy = new StorageContentValidationDecoderPolicy ();
105106 DownloadContentValidationOptions validationOptions = new DownloadContentValidationOptions ()
106107 .setStructuredMessageValidationEnabled (true );
107108
108- Context ctx = new Context (StructuredMessageDecoderPolicy .STRUCTURED_MESSAGE_DECODING_CONTEXT_KEY , true )
109- .addData (StructuredMessageDecoderPolicy .STRUCTURED_MESSAGE_VALIDATION_OPTIONS_CONTEXT_KEY , validationOptions );
109+ Context ctx = new Context (Constants .STRUCTURED_MESSAGE_DECODING_CONTEXT_KEY , true )
110+ .addData (Constants .STRUCTURED_MESSAGE_VALIDATION_OPTIONS_CONTEXT_KEY , validationOptions );
110111
111112 HttpPipelineCallContext context = createMockContext (ctx , null );
112113 // Create a non-GET request (POST)
@@ -126,7 +127,7 @@ public void shouldNotApplyDecodingForNonDownloadResponse() throws MalformedURLEx
126127 assertNotNull (response );
127128 assertEquals (200 , response .getStatusCode ());
128129 // Should not be a DecodedResponse
129- assertFalse (response instanceof StructuredMessageDecoderPolicy .DecodedResponse );
130+ assertFalse (response instanceof StorageContentValidationDecoderPolicy .DecodedResponse );
130131 })
131132 .verifyComplete ();
132133 }
@@ -138,10 +139,10 @@ private HttpPipelineCallContext createMockContext(Context ctx, Long contentLengt
138139 when (context .getHttpRequest ()).thenReturn (request );
139140
140141 if (ctx != null ) {
141- when (context .getData (StructuredMessageDecoderPolicy .STRUCTURED_MESSAGE_DECODING_CONTEXT_KEY ))
142- .thenReturn (ctx .getData (StructuredMessageDecoderPolicy .STRUCTURED_MESSAGE_DECODING_CONTEXT_KEY ));
143- when (context .getData (StructuredMessageDecoderPolicy .STRUCTURED_MESSAGE_VALIDATION_OPTIONS_CONTEXT_KEY ))
144- .thenReturn (ctx .getData (StructuredMessageDecoderPolicy .STRUCTURED_MESSAGE_VALIDATION_OPTIONS_CONTEXT_KEY ));
142+ when (context .getData (Constants .STRUCTURED_MESSAGE_DECODING_CONTEXT_KEY ))
143+ .thenReturn (ctx .getData (Constants .STRUCTURED_MESSAGE_DECODING_CONTEXT_KEY ));
144+ when (context .getData (Constants .STRUCTURED_MESSAGE_VALIDATION_OPTIONS_CONTEXT_KEY ))
145+ .thenReturn (ctx .getData (Constants .STRUCTURED_MESSAGE_VALIDATION_OPTIONS_CONTEXT_KEY ));
145146 } else {
146147 when (context .getData (any ())).thenReturn (java .util .Optional .empty ());
147148 }
0 commit comments