Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*
* @author Honza Brázdil <jbrazdil@redhat.com>
*/
@JsonTypeInfo( use = Id.NAME, include = As.PROPERTY, property = TYPE )
@JsonTypeInfo( use = Id.NAME, include = As.EXISTING_PROPERTY, property = TYPE, visible = true )
@JsonSubTypes( {
@JsonSubTypes.Type( value = FileBuildComponent.class, name = "file" ),
@JsonSubTypes.Type( value = RPMBuildComponent.class, name = "rpm" )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.redhat.red.build.koji.model.json;

import com.fasterxml.jackson.core.JsonParser;
import org.junit.Test;

import java.io.IOException;
Expand All @@ -32,16 +33,18 @@ public class BuildComponentTest
public void jsonRoundTripFile() throws VerificationException, IOException
{
FileBuildComponent src = new FileBuildComponent.Builder( "foo.txt" )
.withFileSize(42)
.withFileSize( 42 )
.withChecksum( "md5", "2a4b3cd54e6f" )
.build();

String json = mapper.writeValueAsString(src);
System.out.println(json);
String json = mapper.writeValueAsString( src );
System.out.println( json );

mapper.reader().with( JsonParser.Feature.STRICT_DUPLICATE_DETECTION ).readTree( json );

BuildComponent out = mapper.readValue( json, BuildComponent.class );

assertThat(out, equalTo(src));
assertThat( out, equalTo( src ) );
}

@Test
Expand All @@ -57,6 +60,8 @@ public void jsonRoundTripRPM() throws VerificationException, IOException
String json = mapper.writeValueAsString( src );
System.out.println( json );

mapper.reader().with( JsonParser.Feature.STRICT_DUPLICATE_DETECTION ).readTree( json );

BuildComponent out = mapper.readValue( json, BuildComponent.class );

assertThat( out, equalTo( src ) );
Expand Down
Loading