Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup null validation when configuring image #768

Merged
merged 6 commits into from
Aug 1, 2018

Conversation

loosebazooka
Copy link
Member

This is just a followup to #750 to cleanup and organize some code

Also cleans up some tests and moves them around

@Test
@SuppressWarnings("JdkObsolete")
public void testBuilder_nullValues() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests were moved to ContainerConfigurationTest

ContainerConfiguration.builder().setEnvironment(ImmutableMap.of()).build());

// Environment map can accept TreeMap and Hashtable.
BuildConfiguration.builder(Mockito.mock(JibLogger.class))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were removed, doesn't make sense to ensure TreeMap/HashMap are valid Map types.

Copy link
Member

@chanseokoh chanseokoh Aug 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I remember: #632 (comment)

The point of the test was to ensure that we don't call things like containsKey(null), because while ImmutableMap is OK with that, some Map implementations like TreeMap throws an exception right away. Maybe adding the issue link as a comment could make this clearer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good point, I'll put them back in.

// Exposed ports element should not be null.
try {
ContainerConfiguration.builder()
.setExposedPorts(Arrays.asList(new Port(1000, Protocol.TCP), null));
Copy link
Member

@chanseokoh chanseokoh Aug 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still not narrow enough. For example, suppose Port was modified to throw IllegalArgumentException when given 1000. The test will still pass if we introduce a bug into .setExposedPorts() that won't throw the exception.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right. Will update

@@ -0,0 +1,76 @@
package com.google.cloud.tools.jib.configuration;

import static org.junit.Assert.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like there's a static wildcard import here.

@@ -0,0 +1,76 @@
package com.google.cloud.tools.jib.configuration;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyright

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

import org.junit.Assert;
import org.junit.Test;

public class ContainerConfigurationTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

short javadoc here

@loosebazooka loosebazooka merged commit 42842a8 into master Aug 1, 2018
@loosebazooka loosebazooka changed the title Cleanup null validation when configuration image Cleanup null validation when configuring image Aug 1, 2018
@chanseokoh chanseokoh deleted the post-labelPR-cleanup branch August 1, 2018 21:38
@chanseokoh
Copy link
Member

I pushed the "Delete Branch" button. You can always restore it later.

coollog pushed a commit that referenced this pull request Aug 2, 2018
* Cleanup null validation when configuration image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants