Skip to content

Commit 98c703e

Browse files
andrzejj0slawekjaranowski
authored andcommitted
Fixing #769
1 parent 0fc892f commit 98c703e

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static Optional<Segment> determineUnchangedSegment( boolean allowMajorUpd
7777
log.info( "Assuming allowMajorUpdates false because allowMinorUpdates is false." );
7878
}
7979

80-
Optional<Segment> unchangedSegment = allowMajorUpdates && allowMinorUpdates
80+
Optional<Segment> unchangedSegment = allowMajorUpdates && allowMinorUpdates && allowIncrementalUpdates
8181
? empty()
8282
: allowMinorUpdates && allowIncrementalUpdates
8383
? of( MAJOR )
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package org.codehaus.mojo.versions.utils;
2+
/*
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
import org.junit.Test;
22+
23+
import static java.util.Optional.empty;
24+
import static java.util.Optional.of;
25+
import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL;
26+
import static org.codehaus.mojo.versions.api.Segment.MAJOR;
27+
import static org.codehaus.mojo.versions.api.Segment.MINOR;
28+
import static org.codehaus.mojo.versions.utils.SegmentUtils.determineUnchangedSegment;
29+
import static org.hamcrest.MatcherAssert.assertThat;
30+
import static org.hamcrest.Matchers.is;
31+
32+
/**
33+
* Unit tests for {@link SegmentUtils}
34+
*/
35+
public class SegmentUtilsTest
36+
{
37+
@Test
38+
public void testIncremental()
39+
{
40+
assertThat( determineUnchangedSegment( false, false, false, null ),
41+
is( of( INCREMENTAL ) ) );
42+
assertThat( determineUnchangedSegment( true, false, false, null ),
43+
is( of( INCREMENTAL ) ) );
44+
assertThat( determineUnchangedSegment( true, true, false, null ),
45+
is( of( INCREMENTAL ) ) );
46+
}
47+
48+
@Test
49+
public void testMinor()
50+
{
51+
assertThat( determineUnchangedSegment( false, false, true, null ),
52+
is( of( MINOR ) ) );
53+
assertThat( determineUnchangedSegment( true, false, true, null ),
54+
is( of( MINOR ) ) );
55+
}
56+
57+
@Test
58+
public void testMajor()
59+
{
60+
assertThat( determineUnchangedSegment( false, true, true, null ),
61+
is( of( MAJOR ) ) );
62+
}
63+
64+
@Test
65+
public void testEmpty()
66+
{
67+
assertThat( determineUnchangedSegment( true, true, true, null ),
68+
is( empty() ) );
69+
}
70+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy