Workflow lab
Split into two teams (team sizes can range from 1 - 3).
You will need two git accounts. A root account where team 1 create the main project repo and to which all other teams get invited.
Other teams create their own accounts.
Team 1 on a suitable location on a machine create the main project (git init and some kind of project structure - files and folders) and link it to the root git repo (git remote add origin…). This becomes team 1’s repo, and also the main repo.
Team 2 should received an invite to team 1’s repo, and should have accepted the invite.
Team 2, using their own git account should git clone their version of the repo on their own machine.
So the same project (git repo) is available in two git repos and on two different machines, each local git repo is tied to different git account i.e. having different ORIGINS.
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
JSONFormatter.java
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…)