Skip to content

Commit 17f274d

Browse files
committed
Code clean up
1 parent 2e90859 commit 17f274d

29 files changed

+229
-215
lines changed

rwx-test/src/main/java/org/commonjava/rwx/test/jira/JiraServerInfo.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@
2020
*/
2121
public final class JiraServerInfo extends AbstractJiraServerInfo
2222
{
23-
private String version;
24-
private String baseUrl;
25-
private String buildDate;
26-
private int buildNumber;
23+
private final String version;
24+
25+
private final String baseUrl;
26+
27+
private final String buildDate;
28+
29+
private final int buildNumber;
30+
2731
private String edition;
32+
2833
private String serverTime;
2934

3035
public JiraServerInfo( String version, String baseUrl, String buildDate, int buildNumber )

rwx-test/src/main/java/org/commonjava/rwx/test/jira/JiraServerInfoConverter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ public class JiraServerInfoConverter implements Converter<AbstractJiraServerInfo
2929
@Override
3030
public AbstractJiraServerInfo parse( Object object )
3131
{
32-
Map<String, Object> map = (Map) object;
32+
Map<String, Object> map = (Map<String, Object>) object;
3333
String version = (String) map.get( "version" );
3434
String baseUrl = (String) map.get( "baseUrl" );
3535
String buildDate = (String) map.get( "buildDate" );
3636
String edition = (String) map.get( "edition" );
3737
String serverTime = (String) map.get( "serverTime" );
3838
int buildNumber = (Integer) map.get( "buildNumber" );
3939

40-
JiraServerInfo ret = new JiraServerInfo(version, baseUrl, buildDate, buildNumber);
41-
ret.setEdition(edition);
42-
ret.setServerTime(serverTime);
40+
JiraServerInfo ret = new JiraServerInfo( version, baseUrl, buildDate, buildNumber );
41+
ret.setEdition( edition );
42+
ret.setServerTime( serverTime );
4343
return ret;
4444
}
4545

rwx-test/src/main/java/org/commonjava/rwx/test/koji/KojiBuildInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public class KojiBuildInfo
100100

101101
public KojiBuildInfo() {}
102102

103-
public KojiBuildInfo(int id, int packageId, String name, String version, String release)
103+
public KojiBuildInfo( int id, int packageId, String name, String version, String release )
104104
{
105105
setId( id );
106106
setPackageId( packageId );

rwx-test/src/main/java/org/commonjava/rwx/test/koji/KojiTagInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class KojiTagInfo
5252

5353
public KojiTagInfo(){}
5454

55-
public KojiTagInfo( String name)
55+
public KojiTagInfo( String name )
5656
{
5757
this.name = name;
5858
}
@@ -84,7 +84,7 @@ public List<String> getArches()
8484

8585
public boolean isLocked()
8686
{
87-
return locked;
87+
return locked != null && locked;
8888
}
8989

9090
public boolean getMavenSupport()

rwx-test/src/main/java/org/commonjava/rwx/test/subclass/Constants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
*/
2121
public class Constants
2222
{
23+
private Constants()
24+
{
25+
throw new UnsupportedOperationException( "This is a utility class and cannot be instantiated" );
26+
}
27+
2328
public static final String NAME = "name";
2429

2530
public static final String VERSION = "version";

rwx-test/src/test/java/org/commonjava/rwx/test/AbstractTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.commonjava.rwx.test.generated.Test_Registry;
2121
import org.junit.BeforeClass;
2222

23-
import javax.xml.stream.XMLStreamException;
2423
import java.io.BufferedReader;
2524
import java.io.IOException;
2625
import java.io.InputStream;
@@ -41,25 +40,25 @@ public static void register()
4140
Registry.setInstance( new Test_Registry() );
4241
}
4342

44-
protected InputStream getXMLStream( final String name ) throws IOException, XMLStreamException
43+
protected InputStream getXMLStream( final String name )
4544
{
4645
return Thread.currentThread().getContextClassLoader().getResourceAsStream( DOC_PATH + name + ".xml" );
4746
}
4847

49-
protected String getXMLString( final String name ) throws IOException, XMLStreamException
48+
protected String getXMLString( final String name ) throws IOException
5049
{
5150
return IOUtils.toString( new InputStreamReader( getXMLStream( name ) ));
5251
}
5352

5453
// Comparing XML string is a bad idea. But we need it in some cases, e.g., kojiListBuildsResponseNIL
5554

56-
protected String getXMLStringIgnoreFormat( final String name ) throws IOException, XMLStreamException
55+
protected String getXMLStringIgnoreFormat( final String name ) throws IOException
5756
{
5857
final BufferedReader reader = new BufferedReader( new InputStreamReader( getXMLStream( name ) ) );
5958
final StringWriter writer = new StringWriter();
6059
final PrintWriter pWriter = new PrintWriter( writer );
6160

62-
String line = null;
61+
String line;
6362
while ( ( line = reader.readLine() ) != null )
6463
{
6564
pWriter.print( line.trim() );

rwx-test/src/test/java/org/commonjava/rwx/test/jira/JiraServerInfoArrayConverterTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.junit.Test;
2121

2222
import java.io.ByteArrayInputStream;
23-
import java.util.List;
2423

2524
import static junit.framework.TestCase.assertEquals;
2625

rwx-test/src/test/java/org/commonjava/rwx/test/jira/JiraServerInfoConverterTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
package org.commonjava.rwx.test.jira;
1717

1818
import org.commonjava.rwx.api.RWXMapper;
19-
import org.commonjava.rwx.core.Registry;
2019
import org.commonjava.rwx.test.AbstractTest;
21-
import org.commonjava.rwx.test.generated.Test_Registry;
22-
import org.junit.BeforeClass;
2320
import org.junit.Test;
2421

2522
import java.io.ByteArrayInputStream;

rwx-test/src/test/java/org/commonjava/rwx/test/koji/KojiMultiCallTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import org.commonjava.rwx.api.RWXMapper;
1919
import org.commonjava.rwx.core.Registry;
20-
import org.commonjava.rwx.error.XmlRpcException;
2120
import org.commonjava.rwx.test.AbstractTest;
2221
import org.junit.Test;
2322

@@ -51,7 +50,7 @@ public void multiCallRequest_renderTest_0() throws Exception
5150

5251
Object renderedKojiNVR = Registry.getInstance().renderTo( kojiNVR );
5352

54-
List params = new ArrayList<>( );
53+
List<Object> params = new ArrayList<>( );
5554
params.add( renderedKojiNVR );
5655
multiCallObj.setParams( params );
5756

@@ -69,7 +68,7 @@ public void multiCallRequest_renderTest() throws Exception
6968
List<MultiCallObj> multiObjs = new ArrayList<>( );
7069

7170
MultiCallObj callObj_1 = new MultiCallObj( "getBuild" );
72-
List params = new ArrayList<>( );
71+
List<Object> params = new ArrayList<>( );
7372
params.add( "org.dashbuilder-dashbuilder-parent-metadata-0.4.0.Final-1" );
7473
callObj_1.setParams( params );
7574
multiObjs.add( callObj_1 );
@@ -143,7 +142,7 @@ public void roundTrip_MultiCallResponse() throws Exception
143142
assertMultiCallResponse( rounded );
144143
}
145144

146-
private void assertMultiCallResponse( MultiCallResponse response ) throws XmlRpcException
145+
private void assertMultiCallResponse( MultiCallResponse response )
147146
{
148147
List<MultiCallValueObj> valueObjs = response.getValueObjs();
149148

@@ -167,15 +166,15 @@ private void assertMultiCallResponse( MultiCallResponse response ) throws XmlRpc
167166
assertEquals( "org.dashbuilder-dashbuilder-parent-metadata", kojiBuildInfo.getPackageName() );
168167

169168
// if we do not know the type, access Map directly
170-
Map<String, Object> data1Map = (Map) data1;
169+
Map<String, Object> data1Map = (Map<String, Object>) data1;
171170
assertEquals( 48475, data1Map.get( "package_id" ) );
172171
assertEquals( 513598, data1Map.get( "build_id" ) );
173172
assertEquals( "org.dashbuilder-dashbuilder-parent-metadata", data1Map.get( "package_name" ) );
174173

175174

176175
// b. verify response from listTags call
177176

178-
List<Object> data2List = (List) data2;
177+
List<Object> data2List = (List<Object>) data2;
179178
assertEquals( 4, data2List.size() );
180179

181180
// if we know the type (KojiTagInfo) in the list, parse the element to it
@@ -186,7 +185,7 @@ private void assertMultiCallResponse( MultiCallResponse response ) throws XmlRpc
186185
// if we do not know the type, access List directly
187186
Object data2_1 = data2List.get( 0 );
188187
assertTrue( data2_1 instanceof Map );
189-
Map<String, Object> data2_1Map = (Map) data2_1;
188+
Map<String, Object> data2_1Map = (Map<String, Object>) data2_1;
190189
assertEquals( "jb-bxms-6.3-candidate", data2_1Map.get( "name" ) );
191190
assertEquals( 8829, data2_1Map.get( "id" ) );
192191
}

rwx-test/src/test/java/org/commonjava/rwx/test/koji/KojiRWXMapperTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717

1818
import org.commonjava.rwx.api.RWXMapper;
1919
import org.commonjava.rwx.test.AbstractTest;
20-
import org.commonjava.rwx.test.simple.RequestWithOneParam;
2120
import org.junit.Test;
2221

2322
import java.io.ByteArrayInputStream;
2423
import java.util.List;
2524

2625
import static junit.framework.TestCase.assertEquals;
26+
import static junit.framework.TestCase.assertNull;
27+
import static junit.framework.TestCase.assertTrue;
2728

2829
/**
2930
* Created by ruhan on 8/2/17.
@@ -113,7 +114,7 @@ private void assertGetBuildResponse( GetBuildResponse response )
113114
assertEquals( "org.dashbuilder-dashbuilder-parent-metadata", buildInfo.getName() );
114115
assertEquals( "1", buildInfo.getRelease() );
115116
assertEquals( "0.4.0.Final_10", buildInfo.getVersion() );
116-
assertEquals( null, buildInfo.getExtra() );
117+
assertNull( buildInfo.getExtra() );
117118
}
118119

119120
@Test
@@ -123,7 +124,7 @@ public void roundTrip_ListBuildResponseNIL() throws Exception
123124
ListBuildResponse parsed =
124125
new RWXMapper().parse( new ByteArrayInputStream( source.getBytes() ), ListBuildResponse.class );
125126

126-
assertEquals( null, parsed.getBuilds() );
127+
assertNull( parsed.getBuilds() );
127128

128129
String rendered = new RWXMapper().render( parsed );
129130

@@ -155,11 +156,11 @@ private void assertListTagsResponse( ListTagsResponse response )
155156
for ( KojiTagInfo tag : tags )
156157
{
157158
assertEquals( Boolean.FALSE, tag.getLocked() );
158-
assertEquals( true, tag.getMavenSupport() );
159-
assertEquals( true, tag.getMavenIncludeAll() );
160-
assertEquals( null, tag.getPermission() );
161-
assertEquals( null, tag.getPermissionId() );
162-
assertEquals( null, tag.getArches() );
159+
assertTrue( tag.getMavenSupport() );
160+
assertTrue( tag.getMavenIncludeAll() );
161+
assertNull( tag.getPermission() );
162+
assertNull( tag.getPermissionId() );
163+
assertNull( tag.getArches() );
163164
}
164165

165166
KojiTagInfo tag0 = tags.get( 0 );

0 commit comments

Comments
 (0)