Skip to content

Commit

Permalink
Merge pull request #439 from refinedmods/release/2.0.0-milestone.3.1
Browse files Browse the repository at this point in the history
Release v2.0.0-milestone.3.1
  • Loading branch information
raoulvdberge authored Oct 30, 2023
2 parents 7adc997 + f0ad4d0 commit 05f3170
Show file tree
Hide file tree
Showing 213 changed files with 4,510 additions and 1,851 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ on:
types: [ opened, synchronize, reopened ]
jobs:
build:
uses: refinedmods/refinedarchitect/.github/workflows/build.yml@v0.8.2
uses: refinedmods/refinedarchitect/.github/workflows/build.yml@v0.9.0
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
type: string
jobs:
draft:
uses: refinedmods/refinedarchitect/.github/workflows/draft-release.yml@v0.8.2
uses: refinedmods/refinedarchitect/.github/workflows/draft-release.yml@v0.9.0
with:
release-type: ${{ inputs.release-type }}
version-number-override: ${{ inputs.version-number-override }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-for-unsupported-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on:
types: [ labeled, unlabeled, reopened ]
jobs:
unsupported-labeler:
uses: refinedmods/refinedarchitect/.github/workflows/issue-for-unsupported-version.yml@v0.8.2
uses: refinedmods/refinedarchitect/.github/workflows/issue-for-unsupported-version.yml@v0.9.0
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- closed
jobs:
publish-release:
uses: refinedmods/refinedarchitect/.github/workflows/publish-release.yml@v0.8.2
uses: refinedmods/refinedarchitect/.github/workflows/publish-release.yml@v0.9.0
secrets: inherit
with:
project-name: 'Refined Storage'
2 changes: 1 addition & 1 deletion .github/workflows/resolved-issue-locking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on:
- cron: '0 0 * * *'
jobs:
lock:
uses: refinedmods/refinedarchitect/.github/workflows/resolved-issue-locking.yml@v0.8.2
uses: refinedmods/refinedarchitect/.github/workflows/resolved-issue-locking.yml@v0.9.0
2 changes: 1 addition & 1 deletion .github/workflows/validate-branch-name.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: Validate branch name
on: [ pull_request ]
jobs:
validate-branch-name:
uses: refinedmods/refinedarchitect/.github/workflows/validate-branch-name.yml@v0.8.2
uses: refinedmods/refinedarchitect/.github/workflows/validate-branch-name.yml@v0.9.0
2 changes: 1 addition & 1 deletion .github/workflows/validate-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on:
types: [ opened, synchronize, reopened, ready_for_review, labeled, unlabeled ]
jobs:
validate-changelog:
uses: refinedmods/refinedarchitect/.github/workflows/validate-changelog.yml@v0.8.2
uses: refinedmods/refinedarchitect/.github/workflows/validate-changelog.yml@v0.9.0
2 changes: 1 addition & 1 deletion .github/workflows/validate-commit-messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: Validate commit messages
on: [ pull_request ]
jobs:
validate-commit-messages:
uses: refinedmods/refinedarchitect/.github/workflows/validate-commit-messages.yml@v0.8.2
uses: refinedmods/refinedarchitect/.github/workflows/validate-commit-messages.yml@v0.9.0
26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.0.0-milestone.3.1] - 2023-10-30

### Added

- "Open Wireless Grid" keybinding.
- Curios integration on Forge.
- Trinkets integration on Fabric.
- Storage Monitor

### Changed

- You can now recharge the Controller in item form.

### Fixed

- Fixed a random Grid crash.

### Removed

- The `useEnergy` config option for the Wireless Grid. If you do not wish to use energy, use the
Creative Wireless Grid.

## [2.0.0-milestone.3.0] - 2023-08-27

### Added
Expand Down Expand Up @@ -455,7 +477,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- The Grid can now use smooth scrolling.
- The Grid now has syntax highlighting for the search query.

[Unreleased]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.3.0...HEAD
[Unreleased]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.3.1...HEAD

[2.0.0-milestone.3.1]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.3.0...v2.0.0-milestone.3.1

[2.0.0-milestone.3.0]: https://github.com/refinedmods/refinedstorage2/compare/v2.0.0-milestone.2.14...v2.0.0-milestone.3.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,24 @@ public long getCapacity() {
public long receive(final long amount, final Action action) {
final long spaceRemaining = capacity - stored;
final long maxReceive = Math.min(amount, spaceRemaining);
if (action == Action.EXECUTE) {
if (maxReceive > 0 && action == Action.EXECUTE) {
stored += maxReceive;
changed();
}
return maxReceive;
}

@Override
public long extract(final long amount, final Action action) {
final long maxExtract = Math.min(stored, amount);
if (action == Action.EXECUTE) {
if (maxExtract > 0 && action == Action.EXECUTE) {
stored -= maxExtract;
changed();
}
return maxExtract;
}

protected void changed() {
// no op
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.refinedmods.refinedstorage2.api.core.Action;
import com.refinedmods.refinedstorage2.api.network.energy.EnergyStorage;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;

Expand Down Expand Up @@ -341,23 +340,4 @@ void shouldExtractFromMultipleSourcesCompletelyMoreThanIsAvailable(final Action

assertThat(sut.getCapacity()).isEqualTo(15);
}

@Test
void shouldNotOverflowStoredAndCapacityCountOnInfiniteEnergyStoragesStoredInComposite() {
// Arrange
final EnergyStorage a = new InfiniteEnergyStorage();
final EnergyStorage b = new InfiniteEnergyStorage();

final CompositeEnergyStorage sut = new CompositeEnergyStorage();
sut.addSource(a);
sut.addSource(b);

// Act
final long stored = sut.getStored();
final long capacity = sut.getCapacity();

// Assert
assertThat(stored).isEqualTo(Long.MAX_VALUE);
assertThat(capacity).isEqualTo(Long.MAX_VALUE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.refinedmods.refinedstorage2.api.core.Action;
import com.refinedmods.refinedstorage2.api.network.energy.EnergyStorage;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -12,6 +13,21 @@
import static org.junit.jupiter.api.Assertions.assertThrows;

class EnergyStorageImplTest {
EnergyStorage sut;
int changeCount;

@BeforeEach
void setUp() {
changeCount = 0;
sut = new EnergyStorageImpl(100) {
@Override
protected void changed() {
super.changed();
changeCount++;
}
};
}

@Test
void testInvalidCapacity() {
// Act
Expand All @@ -25,125 +41,134 @@ void testInvalidCapacity() {
@EnumSource(Action.class)
void shouldNotReceiveEnergyOnZeroCapacityStorage(final Action action) {
// Arrange
final EnergyStorage energyStorage = new EnergyStorageImpl(0);
final EnergyStorage zeroCapacitySut = new EnergyStorageImpl(0) {
@Override
protected void changed() {
super.changed();
changeCount++;
}
};

// Act
final long inserted = energyStorage.receive(1, action);
final long inserted = zeroCapacitySut.receive(1, action);

// Assert
assertThat(inserted).isZero();
assertThat(energyStorage.getStored()).isZero();
assertThat(changeCount).isZero();
assertThat(zeroCapacitySut.getStored()).isZero();
}

@ParameterizedTest
@EnumSource(Action.class)
void shouldReceiveEnergy(final Action action) {
// Arrange
final EnergyStorage energyStorage = new EnergyStorageImpl(100);

// Act
final long inserted = energyStorage.receive(50, action);
final long inserted = sut.receive(50, action);

// Assert
assertThat(inserted).isEqualTo(50);

if (action == Action.EXECUTE) {
assertThat(energyStorage.getStored()).isEqualTo(50);
assertThat(sut.getStored()).isEqualTo(50);
assertThat(changeCount).isEqualTo(1);
} else {
assertThat(energyStorage.getStored()).isZero();
assertThat(sut.getStored()).isZero();
assertThat(changeCount).isZero();
}
}

@ParameterizedTest
@EnumSource(Action.class)
void shouldReceiveEnergyAndReachCapacity(final Action action) {
// Arrange
final EnergyStorage energyStorage = new EnergyStorageImpl(100);

// Act
final long inserted = energyStorage.receive(100, action);
final long inserted = sut.receive(100, action);

// Assert
assertThat(inserted).isEqualTo(100);

if (action == Action.EXECUTE) {
assertThat(energyStorage.getStored()).isEqualTo(100);
assertThat(sut.getStored()).isEqualTo(100);
assertThat(changeCount).isEqualTo(1);
} else {
assertThat(energyStorage.getStored()).isZero();
assertThat(sut.getStored()).isZero();
assertThat(changeCount).isZero();
}
}

@ParameterizedTest
@EnumSource(Action.class)
void shouldReceiveEnergyAndExceedCapacity(final Action action) {
// Arrange
final EnergyStorage energyStorage = new EnergyStorageImpl(100);

// Act
final long inserted = energyStorage.receive(101, action);
final long inserted = sut.receive(101, action);

// Assert
assertThat(inserted).isEqualTo(100);

if (action == Action.EXECUTE) {
assertThat(energyStorage.getStored()).isEqualTo(100);
assertThat(sut.getStored()).isEqualTo(100);
assertThat(changeCount).isEqualTo(1);
} else {
assertThat(energyStorage.getStored()).isZero();
assertThat(sut.getStored()).isZero();
assertThat(changeCount).isZero();
}
}

@ParameterizedTest
@EnumSource(Action.class)
void shouldNotReceiveEnergyWhenFull(final Action action) {
// Arrange
final EnergyStorage energyStorage = new EnergyStorageImpl(100);
energyStorage.receive(100, Action.EXECUTE);
sut.receive(100, Action.EXECUTE);
changeCount = 0;

// Act
final long inserted = energyStorage.receive(100, action);
final long inserted = sut.receive(100, action);

// Assert
assertThat(inserted).isZero();
assertThat(energyStorage.getStored()).isEqualTo(100);
assertThat(changeCount).isZero();
assertThat(sut.getStored()).isEqualTo(100);
}

@ParameterizedTest
@EnumSource(Action.class)
void shouldExtractEnergyPartly(final Action action) {
// Arrange
final EnergyStorage energyStorage = new EnergyStorageImpl(100);
energyStorage.receive(100, Action.EXECUTE);
sut.receive(100, Action.EXECUTE);
changeCount = 0;

// Act
final long extracted = energyStorage.extract(99, action);
final long extracted = sut.extract(99, action);

// Assert
assertThat(extracted).isEqualTo(99);

if (action == Action.EXECUTE) {
assertThat(energyStorage.getStored()).isEqualTo(1);
assertThat(sut.getStored()).isEqualTo(1);
assertThat(changeCount).isEqualTo(1);
} else {
assertThat(energyStorage.getStored()).isEqualTo(100);
assertThat(sut.getStored()).isEqualTo(100);
assertThat(changeCount).isZero();
}
}

@ParameterizedTest
@EnumSource(Action.class)
void shouldExtractEnergyCompletely(final Action action) {
// Arrange
final EnergyStorage energyStorage = new EnergyStorageImpl(100);
energyStorage.receive(50, Action.EXECUTE);
sut.receive(50, Action.EXECUTE);
changeCount = 0;

// Act
final long extracted = energyStorage.extract(51, action);
final long extracted = sut.extract(51, action);

// Assert
assertThat(extracted).isEqualTo(50);

if (action == Action.EXECUTE) {
assertThat(energyStorage.getStored()).isZero();
assertThat(sut.getStored()).isZero();
assertThat(changeCount).isEqualTo(1);
} else {
assertThat(energyStorage.getStored()).isEqualTo(50);
assertThat(sut.getStored()).isEqualTo(50);
assertThat(changeCount).isZero();
}
}
}
Loading

0 comments on commit 05f3170

Please sign in to comment.