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

[WIP] "Not enough comments" #607 patch #646

Draft
wants to merge 6 commits into
base: uinverse
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 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
@@ -1,23 +1,39 @@
// Constants.java
// Constants

// add this specific class (Constants) to the package named com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl
package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl;

/**
* Constants
*/
public class Constants {

// a public, static constant property of the class Constants defined on line 10 of type string called AN_ATTEMPT_WAS_MADE_TO_DIVIDE_BY_ZERO which contains the text "An attempt was made to divide by zero."
public static final String AN_ATTEMPT_WAS_MADE_TO_DIVIDE_BY_ZERO = "An attempt was made to divide by zero.";
// a public, static constant property of the class Constants defined on line 10 of type string called BUZZ which contains the text "Buzz"
public static final String BUZZ = "Buzz";
// a public, static constant property of the class Constants defined on line 10 of type string called COM_SERIOUSCOMPANY_BUSINESS_JAVA_FIZZBUZZ_PACKAGENAMINGPACKAGE_IMPL_PRINTERS_INTEGER_INTEGER_PRINTER_PRINT which contains the text "com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers.IntegerIntegerPrinter.print()"
public static final String COM_SERIOUSCOMPANY_BUSINESS_JAVA_FIZZBUZZ_PACKAGENAMINGPACKAGE_IMPL_PRINTERS_INTEGER_INTEGER_PRINTER_PRINT = "com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers.IntegerIntegerPrinter.print()";
// a public, static constant property of the class Constants defined on line 10 of type string called FIZZ which contains the text "Fizz"
public static final String FIZZ = "Fizz";
// a public, static constant property of the class Constants defined on line 10 of type string called LINE_SEPARATOR which contains the text "line.separator"
public static final String LINE_SEPARATOR = "line.separator";
// a public, static constant property of the class Constants defined on line 10 of type string called LOOP_COMPONENT_FACTORY which contains the text "loopComponentFactory"
public static final String LOOP_COMPONENT_FACTORY = "loopComponentFactory";
// a public, static constant property of the class Constants defined on line 10 of type string called SPRING_XML which contains the text "spring.xml"
public static final String SPRING_XML = "spring.xml";
// a public, static constant property of the class Constants defined on line 10 of type string called STANDARD_FIZZ_BUZZ which contains the text "standardFizzBuzz"
public static final String STANDARD_FIZZ_BUZZ = "standardFizzBuzz";
// a public, static constant property of the class Constants defined on line 10 of type string called THE_INTEGERS_COULD_NOT_BE_COMPARED which contains the text "The integers could not be compared."
public static final String THE_INTEGERS_COULD_NOT_BE_COMPARED = "The integers could not be compared.";
// a public, static constant property of the class Constants defined on line 10 of type int called DEFAULT_FIZZ_BUZZ_UPPER_LIMIT_PARAMETER_VALUE which contains the number 100
public static final int DEFAULT_FIZZ_BUZZ_UPPER_LIMIT_PARAMETER_VALUE = 100;
// a public, static constant property of the class Constants defined on line 10 of type int called INTEGER_DIVIDE_ZERO_VALUE which contains the number 0
public static final int INTEGER_DIVIDE_ZERO_VALUE = 0;
// a public, static constant property of the class Constants defined on line 10 of type int called INTEGER_ORIGIN_ZERO_VALUE which contains the number 0
public static final int INTEGER_ORIGIN_ZERO_VALUE = 0;
// a public, static constant property of the class Constants defined on line 10 of type int called LOOP_INC_VALUE which contains the number 1
public static final int LOOP_INC_VALUE = 1;
// a public, static constant property of the class Constants defined on line 10 of type int called LOOP_INIT_VALUE which contains the number 1
public static final int LOOP_INIT_VALUE = 1;

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
// Main.java
// Main

// add this specific class (Main) to the package named com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl
package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl;

// import package org.springframework.context.ApplicationContext
// import package org.springframework.context.ConfigurableApplicationContext
// import package org.springframework.context.support.ClassPathXmlApplicationContext
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

// import package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.parameters.DefaultFizzBuzzUpperLimitParameter
// import package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz
// import package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.parameters.FizzBuzzUpperLimitParameter
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.parameters.DefaultFizzBuzzUpperLimitParameter;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.parameters.FizzBuzzUpperLimitParameter;
Expand All @@ -14,16 +24,20 @@
public final class Main {

/**
* @param args
* the main function to the class Main declared in com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl; the starting point to the application
* @param args The command line arguments passed in from the command line, which are used to change the end effects of the program if used as a Command Line Interface, or CLI, tool. This is declared as `final`, which is a keyword used in Java to declare any variable as a constant, meaning that it cannot be changed after declaration. This specfic program does not use this argument, as this is just an Enterprise Quality(TM) FizzBuzz program which does not need any arguments passed in on execution, but other projects which are less Enterprise Quality(TM) have used it.
*/
public static void main(final String[] args) {
// create an object off of ClassPathXmlApplicationContent imported from org.springframework.context.support.ClassPathXmlApplicationContent on line 12 called context of type ApplicationContext, passing in Constants.SPRING_XML
final ApplicationContext context = new ClassPathXmlApplicationContext(Constants.SPRING_XML);
// create an object called myFizzBuzz of type FizzBuzz by calling method getBean from context declared on line 31 and passing in Contants.STANDARD_FIZZ_BUZZ
final FizzBuzz myFizzBuzz = (FizzBuzz) context.getBean(Constants.STANDARD_FIZZ_BUZZ);
// create an object of type FizzBuzzUpperLimitParamater imported from com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.parameters.FizzBuzzUpperLimitParameter on line 19, using class DefaultFizzBuzzUpperLimit imported from com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.parameters.DefaultFizzBuzzUpperLimitParameter on line 17
final FizzBuzzUpperLimitParameter fizzBuzzUpperLimit = new DefaultFizzBuzzUpperLimitParameter();
// call method fizzBuzz on constant myFizzBuzz declared on line 33
myFizzBuzz.fizzBuzz(fizzBuzzUpperLimit.obtainUpperLimitValue());

// call method close on context declared on line 31 casted to ConfigurableApplicationContext imported from org.springframework.context.ConfigurableApplicationContect on line 11
((ConfigurableApplicationContext) context).close();

}

}
Original file line number Diff line number Diff line change
@@ -1,36 +1,50 @@
// StandardFizzBuzz.java
// Standard FizzBuzz

// add this specific class (StandardFizzBuzz) to the package named com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl
package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl;

// import package org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Autowired;
// import package org.springframework.stereotype.Service
import org.springframework.stereotype.Service;

// import package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz;
// import package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.FizzBuzzSolutionStrategyFactory
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.FizzBuzzSolutionStrategyFactory;
// import package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.FizzBuzzSolutionStrategy
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.FizzBuzzSolutionStrategy;

/**
* Standard FizzBuzz
*/
@Service
public class StandardFizzBuzz implements FizzBuzz {

// create a private contstant called _fizzBuzzSolutionStrategyFactory of type FizzBuzzSolutionStrategyFactory imported from com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.FizzBuzzSolutionStrategyFactory on line 15

Choose a reason for hiding this comment

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

Typo, should read "constant"

private final FizzBuzzSolutionStrategyFactory _fizzBuzzSolutionStrategyFactory;

/**
* the constructor for the class StandardFizzBuzz declared on line 23
* @param _fizzBuzzSolutionStrategyFactory
*/
@Autowired
public StandardFizzBuzz(final FizzBuzzSolutionStrategyFactory _fizzBuzzSolutionStrategyFactory) {
// call the constructor of the class StandardFizzBuzz declared on line 13
super();
// set the value of the constant _fizzBuzzSolutionStrategyFactory, a property on the current object declared on line 25, to the value of _fizzBuzzSolutionStrategyFactory, the parameter to the constructor of StandardFizzBuzz declared on line 23, declared on line 32
this._fizzBuzzSolutionStrategyFactory = _fizzBuzzSolutionStrategyFactory;
}

/**
* the method fizzBuzz on the class StandardFizzBuzz declared on line 23
* @param nFizzBuzzUpperLimit
*/
public void fizzBuzz(final int nFizzBuzzUpperLimit) {
// a constant called mySolutionStrategy of type FizzBuzzSolutionStrategy imported from com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.FizzBuzzSolutionStrategy on line 17, which is set to the return value of the method createFizzBuzzSolutionStrategy on the property _fizzBuzzSolutionStrategy of this object declared on line 25
final FizzBuzzSolutionStrategy mySolutionStrategy =
this._fizzBuzzSolutionStrategyFactory.createFizzBuzzSolutionStrategy();
// run the method runSolution on the object mySolutionStrategy declared on lines 45-46 of type FizzBuzzSolutionStrategy and pass in the parameter to this function called nFizzBuzzUpperLimit of type int
mySolutionStrategy.runSolution(nFizzBuzzUpperLimit);
}

}
50 changes: 49 additions & 1 deletion src/test/java/FizzBuzzTest.java
Original file line number Diff line number Diff line change
@@ -1,85 +1,133 @@
// FizzBuzzTest.java
// Tests for FizzBuzz

// import method assertEquals from package org.junit.Assert
import static org.junit.Assert.assertEquals;

// import package java.io.BufferedOutputStream
import java.io.BufferedOutputStream;
// import package java.io.ByteArrayOutputStream
import java.io.ByteArrayOutputStream;
// import package java.io.IOException
import java.io.IOException;
// import package java.io.PrintStream
import java.io.PrintStream;

// import package org.junit.After
import org.junit.After;
// import package org.junit.Before
import org.junit.Before;
// import package org.junit.Test
import org.junit.Test;
// import package org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContext;
// import package org.springframework.context.ConfigurableApplicationContext
import org.springframework.context.ConfigurableApplicationContext;
// import package org.springframework.context.support.ClassPathXmlApplicationContext
import org.springframework.context.support.ClassPathXmlApplicationContext;

// import package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz;

/**
* Tests for FizzBuzz
*/
public class FizzBuzzTest {

// create a private property on class FizzBuzzTest declared on line 35 called out of type PrintStream imported from import java.io.PrintStream on line 14
private PrintStream out;
// create a private property on class FizzBuzzTest declared on line 35 called fb of type FizzBuzz imported from import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz on line 30
private FizzBuzz fb;

/**
* setUp method on class FizzBuzzTest declared on line 35 sets up object for tests
* @return void
*/
@Before
public void setUp() {
// declare an object called context of type ApplicationContext imported from org.springframework.context.ApplicationContext on line 23, based on ClassPathXmlApplicationContext imported from org.springframework.context.support.ClassPathXmlApplicationContext on line 27 passing in test constant SPRING_XML
final ApplicationContext context = new ClassPathXmlApplicationContext(TestConstants.SPRING_XML);
// set the value of the property fb of the current object declared on line 39 to the return value of the method getBean on the object context of type ApplicationContext declared on line 48 passing in the test constant STANDARD_FIZZ_BUZZ casted to the type FizzBuzz imported from import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz on line 30
this.fb = (FizzBuzz) context.getBean(TestConstants.STANDARD_FIZZ_BUZZ);
// set the print stream for this class to System.out, by setting the value of the property out of the current object declared on line 37
this.out = System.out;
// call the method close on the object context declared on line 48 casted to type ConfigurableApplicationContext imported from org.springframework.context.ConfigurableApplicationContext on line 25
((ConfigurableApplicationContext) context).close();
}

/**
* tearDown method on class FizzBuzzTest declared on line 35 deconstructs object and sets everything back to defaults
* @return void
*/
@After
public void tearDown() {
// set the system output to the value of the property out on the current object, which should be set to System.out due to it being set on line 52 in method setUp of class FizzBuzzTest declared on line 35
System.setOut(this.out);
}

/**
* do the fizzbuzz; see method testFizzBuzz on class FizzBuzzTest declared on line 35 declared on line 98
* @param n int
* @param s String
* @throws IOException
*/
private void doFizzBuzz(final int n, final String s) throws IOException {
// create a constant of type ByteArrayOutputStream imported from java.io.ByteArrayOutputStream on line 10 called baos
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
// create a constant of type BufferedOutputStream imported from java.io.BufferedOutputStream on line 8 called bos, and pass in baos declared on line 75 to the constructor
final BufferedOutputStream bos = new BufferedOutputStream(baos);
// set the system output to the returned object of the constructor for PrintStream imported from java.io.PrintStream on line 14 passing in bos declared on line 77
System.setOut(new PrintStream(bos));

// call the method fizzBuzz on the property fb of the current object, passing in the constant parameter n of type int
this.fb.fizzBuzz(n);

// flush the system ouput by running the method flush on the property out on the class System
System.out.flush();
// create a string variable called platformDependentExpectedResult which replaces all of the newlines in the constant parameter s of type string with the system line seperator, fetched by passing "line.seperator" to the method getProperty on class System
String platformDependentExpectedResult = s.replaceAll("\\n", System.getProperty("line.separator"));
Copy link
Author

Choose a reason for hiding this comment

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

Notes for anyone in the future; this line of code is currently not Enterprise Quality™ due to the fact that it does not import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.Constants and use the constant LINE_SEPERATOR. To make this Enterprise Quality™, is it possible for somebody to start a pull request to change this singular line of code and make it follow industry standard by adding as many imports as possible to greatly optimize the code?

// assert that the value of platformDependentExpectedResult declared on line 87 is equal to the string-casted value of baos declared on line 75
assertEquals(platformDependentExpectedResult, baos.toString());
}

/**
* does the fizzbuzz; see method doFizzBuzz on class FizzBuzzTest declared on line 35 declared on line 73
* @throws IOException
* @return void
*/
@Test
public void testFizzBuzz() throws IOException {
// run the method doFizzBuzz of the current object, passing in the test constant INT_1 as n and the test constant _1_ as s
this.doFizzBuzz(TestConstants.INT_1, TestConstants._1_);
// run the method doFizzBuzz of the current object, passing in the test constant INT_2 as n and the test constant _1_2 as s
this.doFizzBuzz(TestConstants.INT_2, TestConstants._1_2_);
// run the method doFizzBuzz of the current object, passing in the test constant INT_3 as n and the test constant _1_2_FIZZ as s
this.doFizzBuzz(TestConstants.INT_3, TestConstants._1_2_FIZZ);
// run the method doFizzBuzz of the current object, passing in the test constant INT_4 as n and the test constant _1_2_FIZZ_4 as s
this.doFizzBuzz(TestConstants.INT_4, TestConstants._1_2_FIZZ_4);
// run the method doFizzBuzz of the current object, passing in the test constant INT_5 as n and the test constant _1_2_FIZZ_4_BUZZ as s
this.doFizzBuzz(TestConstants.INT_5, TestConstants._1_2_FIZZ_4_BUZZ);
// run the method doFizzBuzz of the current object, passing in the test constant INT_6 as n and the test constant _1_2_FIZZ_4_BUZZ_FIZZ as s
this.doFizzBuzz(TestConstants.INT_6, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ);
// run the method doFizzBuzz of the current object, passing in the test constant INT_7 as n and the test constant _1_2_FIZZ_4_BUZZ_FIZZ_7 as s
this.doFizzBuzz(TestConstants.INT_7, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7);
// run the method doFizzBuzz of the current object, passing in the test constant INT_8 as n and the test constant _1_2_FIZZ_4_BUZZ_FIZZ_7_8 as s
this.doFizzBuzz(TestConstants.INT_8, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8);
// run the method doFizzBuzz of the current object, passing in the test constant INT_9 as n and the test constant _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ as s
this.doFizzBuzz(TestConstants.INT_9, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ);
// run the method doFizzBuzz of the current object, passing in the test constant INT_10 as n and the test constant _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ as s
this.doFizzBuzz(TestConstants.INT_10, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ);
// run the method doFizzBuzz of the current object, passing in the test constant INT_11 as n and the test constant _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11 as s
this.doFizzBuzz(TestConstants.INT_11, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11);
// run the method doFizzBuzz of the current object, passing in the test constant INT_12 as n and the test constant _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ as s
this.doFizzBuzz(TestConstants.INT_12, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ);
// run the method doFizzBuzz of the current object, passing in the test constant INT_13 as n and the test constant _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13 as s
this.doFizzBuzz(TestConstants.INT_13, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13);
// run the method doFizzBuzz of the current object, passing in the test constant INT_14 as n and the test constant _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14 as s
this.doFizzBuzz(TestConstants.INT_14, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14);
// run the method doFizzBuzz of the current object, passing in the test constant INT_15 as n and the test constant _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14_FIZZ_BUZZ as s
this.doFizzBuzz(TestConstants.INT_15,
TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14_FIZZ_BUZZ);
// run the method doFizzBuzz of the current object, passing in the test constant INT_16 as n and the test constant _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14_FIZZ_BUZZ_16 as s
this.doFizzBuzz(TestConstants.INT_16,
TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14_FIZZ_BUZZ_16);
}
Expand Down
Loading