Skip to content

Commit

Permalink
Address some compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mprimi committed Sep 25, 2020
1 parent 1cf26db commit 7241b0e
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ResourceLoader resourceLoader() {
@Bean
ArgumentDelegates.CacheArguments cacheArguments() {
// Cannot use @TempDir here because static class initialization via annotation
final File temp = Files.temporaryFolder();
final File temp = Files.newTemporaryFolder();
final ArgumentDelegates.CacheArguments mock = Mockito.mock(ArgumentDelegates.CacheArguments.class);
Mockito.when(mock.getCacheDirectory()).thenReturn(temp);
return mock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
package com.netflix.genie.ui.controllers;

import org.assertj.core.api.Assertions;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
Expand Down Expand Up @@ -52,7 +50,7 @@ void setup() {
*/
@Test
void canGetIndex() {
Assert.assertThat(this.controller.getIndex(), Matchers.is("index"));
Assertions.assertThat(this.controller.getIndex()).isEqualTo("index");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ private void submitAndCheckJob(final int documentationId, final boolean archiveJ
this.waitForDone(id);

this.checkJobStatus(documentationId, id);
this.checkJob(documentationId, id, commandArgs, archiveJob);
this.checkJob(documentationId, id, commandArgs);
if (archiveJob) {
this.checkJobOutput(documentationId, id);
}
Expand All @@ -309,7 +309,7 @@ private void submitAndCheckJob(final int documentationId, final boolean archiveJ
this.checkJobCommand(documentationId, id);
this.checkJobApplications(documentationId, id);
this.checkFindJobs(documentationId, id, JOB_USER);
this.checkJobArchive(id, archiveJob);
this.checkJobArchive(id);

Assertions.assertThat(this.jobRepository.count()).isEqualTo(1L);

Expand Down Expand Up @@ -425,8 +425,7 @@ private void checkJobStatus(final int documentationId, final String id) {
private void checkJob(
final int documentationId,
final String id,
final List<String> commandArgs,
final boolean archiveJob
final List<String> commandArgs
) {
final RestDocumentationFilter getResultFilter = RestAssuredRestDocumentation.document(
"{class-name}/" + documentationId + "/getJob/",
Expand Down Expand Up @@ -987,26 +986,14 @@ private void testForConflicts(
}

private void checkJobArchive(
final String id,
final boolean jobShouldBeArchived
final String id
) {
final Path archiveDirectory = Paths.get(this.jobsLocationsProperties.getArchives()).resolve(id);
// TODO: This is flipped during V4 migration and should be changed back once clients are fixed
// if (jobShouldBeArchived) {
Assertions.assertThat(Files.exists(archiveDirectory)).isTrue();
Assertions.assertThat(Files.isDirectory(archiveDirectory)).isTrue();
// } else {
// Assertions.assertThat(Files.exists(archiveDirectory)).isFalse();
// }
}

// @Test
// public void testSubmitJobMethodTwiceSuccess() throws Exception {
// submitAndCheckJob(2, true);
// cleanup();
// setup();
// submitAndCheckJob(3, false);
// }

@Test
void canSubmitJobWithAttachments() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ private int read(final byte[] destination) throws IOException {
// Read from current chunk into destination
final int leftInCurrentChunk = this.currentChunk.size() - this.currentChunkWatermark;
final int bytesRead = Math.min(leftInCurrentChunk, destination.length);
this.currentChunk.copyTo(destination, currentChunkWatermark, 0, bytesRead);
this.currentChunk.substring(currentChunkWatermark, currentChunkWatermark + bytesRead)
.copyTo(destination, 0);

// Update watermark
this.currentChunkWatermark += bytesRead;
Expand Down
14 changes: 0 additions & 14 deletions genie-web/src/main/java/com/netflix/genie/web/util/UNIXUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,4 @@ public static void changeOwnershipOfDirectory(
.addArgument(dir);
executor.execute(commandLine);
}

/**
* Give write permission to the group owning a given file or directory.
*
* @param path the path
* @param executor the command executor
* @throws IOException if the operation fails
*/
public static void makeDirGroupWritable(final String path, final Executor executor) throws IOException {
log.debug("Adding write permissions for the directory {} for the group.", path);
final CommandLine commandLIne = new CommandLine(SUDO).addArgument("chmod").addArgument("g+w")
.addArgument(path);
executor.execute(commandLIne);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
*
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.netflix.genie.web.tasks.leader

import com.netflix.genie.web.tasks.GenieTaskScheduleType
import spock.lang.Specification

class LeaderTaskSpec extends Specification {

def "Test simple concrete subclass"() {
setup:
LeaderTask task = new TestLeaderTask()

when:
task.run()

then:
task.runCount == 1

when:
task.getTrigger()

then:
thrown(UnsupportedOperationException)

when:
task.getFixedRate()

then:
thrown(UnsupportedOperationException)

when:
task.getFixedDelay()

then:
thrown(UnsupportedOperationException)

when:
task.cleanup()

then:
noExceptionThrown()

expect:
task.getScheduleType() == GenieTaskScheduleType.FIXED_DELAY
}

private static class TestLeaderTask extends LeaderTask {

def runCount = 0

@Override
GenieTaskScheduleType getScheduleType() {
return GenieTaskScheduleType.FIXED_DELAY
}

@Override
void run() {
runCount++
}
}
}

0 comments on commit 7241b0e

Please sign in to comment.