blob: 793a9841ace4beb312780fb5870edf4f59e7c13e [file] [log] [blame]
/*
* Copyright (c) 2011 Google Inc.
*
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
*
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.ui.builder.protoc.output;
import static org.mockito.Mockito.*;
import org.eclipse.core.runtime.CoreException;
import org.junit.*;
/**
* Tests for <code>{@link RegexOutputParser#parseAndAddMarkerIfNecessary(String, ProtocMarkerFactory)}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
public class RegexOutputParser_parseAndAddMarkerIfNecessary_withLineNumber_Test {
private ProtocMarkerFactory markerFactory;
private RegexOutputParser parser;
@Before public void setUp() {
markerFactory = mock(ProtocMarkerFactory.class);
parser = new RegexOutputParser("(.*):(.*):(.*)", 1, 2, 3);
}
@Test public void should_not_create_IMarker_if_line_does_not_match_error_pattern() throws CoreException {
String line = "Expected field name.";
parser.parseAndAddMarkerIfNecessary(line, markerFactory);
verifyZeroInteractions(markerFactory);
}
@Test public void should_attempt_to_create_IMarker_if_line_matches_error_pattern() throws CoreException {
String line = "person.proto:10:Cannot generate Java.";
parser.parseAndAddMarkerIfNecessary(line, markerFactory);
verify(markerFactory).createErrorIfNecessary("person.proto", 10, "Cannot generate Java.");
}
}