Split into two teams (team sizes can range from 1 - 3).
Team 1 must set the project up (locally). It should be an empty maven project with NO code. Team 1 should also create a git repo on the cloud. Once team 1 have created the cloud git repo they should invite team 2, team 2 should get an invite from team 1 join the git repo.
Team 2 should create the git repo in the cloud. Team 2 should have received an invite from team 1 to join their repo. They should join the team 1’s repo.
Finally team 2 should clone the shared project - this can be through a git clone or git pull.
Activities
Team 1
Create the following piece of code
Unit Test - NameBuilderTest.java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.celestial.gitflow.walkthrough; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; /** * * @author Selvyn */ public class NameBuilderTest { public NameBuilderTest() { } // TODO add test methods here. // The methods must be annotated with annotation @Test. For example: // @Test public void test_null_params_result_empty_name() { // arrange NameBuilder cut = new NameBuilder(); String[] input = {}; String expected = ""; // act String actual = cut.buildName( input ); // assert assertEquals(expected, actual); } }
Class Under Test - NameBuilder.java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.celestial.gitflow.walkthrough; /** * * @author Selvyn */ class NameBuilder { public String buildName(String[] input) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }
Once completed push your code to the repo
Team 2
Unit Test - JSONFormatterTest.java
package com.celestial.gitflow.team2; import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; class JSONFormatterTest { @Test void test() { // arrange JSONFormatter cut = new JSONFormatter(); String input = "{}"; String expected = "{}"; // act String actual = cut.format( input ); // assert assertEquals(expected, actual); } }
Class Under Test - JSONFormatter.java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.celestial.gitflow.team2; /** * * @author Selvyn */ class JSONFormatter { String format(String input) { return __format(input); } private String __format( String inputStream ) { return inputStream; } }
JSONFormatter.java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.celestial.gitflow.team2; /** * * @author Selvyn */ public interface Formatter { String format( String dataStream ); }
Once completed push your code to the repo
Depending on which team pushed their code to the repo first, the later team will get a merge conflict.
Use git pull --rebase origin master
Use git status to see where conflicts are
Once conflict has been resolved, push the changes to the repo (no need to perform git add, and git commit, simply use git push…)